我是新來的asp.net和c#,我一直試圖複製和應用程序完成在PHP使用MVC3,從同一個數據庫生成的代碼。我有一個關於在我的「詳細信息」視圖中顯示詳細記錄的問題。ASP.NET通過Razor顯示相關的詳細記錄
namespace MvcApplication5.Models
{
[DataContract(IsReference = true)]
[KnownType(typeof(masterDomain))]
[KnownType(typeof(masterFIP))]
[KnownType(typeof(masterSFPF))]
[KnownType(typeof(rgCountiesServed))]
[KnownType(typeof(rgKeyword))]
[KnownType(typeof(rgServicesProvided))]
public partial class rgOrganization
{
public rgOrganization()
{
this.rgCountiesServeds = new HashSet<rgCountiesServed>();
this.rgKeywords = new HashSet<rgKeyword>();
this.rgServicesProvideds = new HashSet<rgServicesProvided>();
}
[DataMember]
public int orgID { get; set; }
[DataMember]
public string ORGANIZATION { get; set; }
[DataMember]
public string CONTACT_PERSON { get; set; }
[DataMember]
public string PHONE_NUMBER { get; set; }
[DataMember]
public string FAX_NUMBER { get; set; }
[DataMember]
public string EMAIL_ADDRESS { get; set; }
[DataMember]
public string WEBSITE { get; set; }
[DataMember]
public string STREET_1 { get; set; }
[DataMember]
public string STREET_2 { get; set; }
[DataMember]
public string CITY { get; set; }
[DataMember]
public string ZIP_CODE { get; set; }
[DataMember]
public string COUNTY { get; set; }
[DataMember]
public string FIPS { get; set; }
[DataMember]
public string MAILING_ADDRESS { get; set; }
[DataMember]
public Nullable<int> SFPF { get; set; }
[DataMember]
public Nullable<int> DOMAIN { get; set; }
[DataMember]
public virtual masterDomain masterDomain { get; set; }
[DataMember]
public virtual masterFIP masterFIP { get; set; }
[DataMember]
public virtual masterSFPF masterSFPF { get; set; }
[DataMember]
public virtual ICollection<rgCountiesServed> rgCountiesServeds { get; set; }
[DataMember]
public virtual ICollection<rgKeyword> rgKeywords { get; set; }
[DataMember]
public virtual ICollection<rgServicesProvided> rgServicesProvideds { get; set; }
}
查看代碼
@model MvcApplication5.Models.rgOrganization
@{
ViewBag.Title = @Html.DisplayFor(model => model.ORGANIZATION);
}
@section Scripts {
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"></script>
}
<h2>@Html.DisplayFor(model => model.ORGANIZATION)</h2>
<h3><span id="mailing_address">
@Html.DisplayFor(model => model.MAILING_ADDRESS)
</span></h3>
<fieldset>
<legend> @Html.DisplayFor(model => model.COUNTY) COUNTY</legend>
<div class="display-field">
<strong>@Html.DisplayFor(model => model.ORGANIZATION)</strong>
</div>
<div class="display-field">
@Html.DisplayFor(model => model.CONTACT_PERSON)
</div>
<!-- would like to display services provided here -->
</fieldset>
我的問題是我怎麼通過剃刀訪問「rgCountiesServeds'and 'rgServicesProvideds'?
根據您的觀點,「rgOrganization」代表什麼類型並不十分清楚。你應該顯示你的視圖代碼。 –