Should I create a new MVC 4 Model or use existing one with redundant
properties
I have for example the following MVC Model.
public class Fruits
{
public int FruitId {get;set;}
public string Name {get;set;}
public string Type {get;set;}
public double Price {get;set;}
public int InStock {get;set;}
public bool BulkDiscount {get;set;}
public string PhotoUrl {get;set;}
public string Url {get;set;}
public List<Fruits> SimilarFruits {get;set;}
}
This model is used to populate a page with the relevant data which is
fine. However, now I want to get a list of Fruits that users purchased
that were similar to the current fruit.
I can write the database query to get the data which is fine. But is the
best way for me to re-use the class Fruits even though I'm only interested
in the properties
public string Name {get;set;}
public string PhotoUrl {get;set;}
public string Url {get;set;}
So I could create a list of Fruits like
List<Fruits> SimilarFruitList = new List<Fruits>();
No comments:
Post a Comment