I want to make a class that I will use as a model in a strongly typed view in an asp.net-mvc application:
public class MaterialAssetDetails { public int Id {get;set;} public string ItemNumber {get;set;} public string Name {get;set;} public string MeasureUnit {get;set;} public decimal Amount {get;set;} public decimal Price {get;set;} public MaterialAssetDetails(int id, string itemNumber, string Name, string measureUnit, decimal amount, decimal price) { this.Id = id; this.ItemNumber=itemNumber; //и так далее } } The purpose of this : displaying detailed information about the tangible asset .
What I don't like: the number of parameters that need to be passed to the constructor (and these are not all the properties) for creating an object instance.
Tell me how do you do with similar classes?
PS: it only occurs to me to create an overloaded version of the constructor without parameters amount , price :
public MaterialAssetDetails(int id, string itemNumber, string name, string measureUnit) :this(id, itemNumber, name, measureUnit, 0,0) { }