0
在我的MVC 3應用程序,我有以下你如何計算的屬性來完成這個
public class SalesPerson
{
public SalesPerson()
{
this.SalesOrders = new HashSet<SalesOrder>();
this.Ups = new HashSet<Up>();
}
public int SalesPersonId { get; set; }
public int StoreId { get; set; }
public Store Store { get; set; }
public string StoreAndCode
{
get
{
return Store.Code + ", " + Store;
}
}
我假設我有實例中的return語句,商店,以實際得到的代碼和退貨名稱?我怎麼寫這個,以便我可以在相應的視圖中公開這個?
您是否問如何將您的StoreAndCode屬性公開到您的MVC視圖? –
或者你問如何從數據庫中加載'Store'? – Slauma
對不起,這個問題有點模糊!我試圖在Store Store屬性中創建計算好的Propery(Store和代碼)。我假設我必須以某種方式實例化存儲以便能夠螃蟹代碼和名稱以便返回它?現在,我得到一個NullReferenceException,因爲它是我創建一個新的商店對象。 – MissioDei