What is the best way to add two fields and store the sum in third field in asp.net mvc automatically -
i have model class order this,
public class order { public int orderid {get; set;} [datatype(datatype.currency)] [column(typename = "money")] public decimal unitprice { get; set; } public int quantity { get; set; } [datatype(datatype.currency)] [column(typename = "money")] public decimal totalamount { get; set; } }
i want add 2 fields unitprice , quantity , store sum in totalamount field. best way this?
you can way:
public class order { public int orderid {get; set;} [datatype(datatype.currency)] [column(typename = "money")] public decimal unitprice { get; set; } public int quantity { get; set; } [datatype(datatype.currency)] [column(typename = "money")] public decimal totalamount { {return unitprice * quantity; } } }
Comments
Post a Comment