Reputation: 809
In my MVC 3 app I have the following
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;
}
}
I am assuming that I have to instantiate the store in the return statement in order to actually get the code and name for the return? How would I write this so I can expose this in the corresponding view?
Upvotes: 0
Views: 106
Reputation: 3952
Set your property to virtual.
public class SalesPerson
{
...
public virtual Store Store { get; set; }
}
Upvotes: 1