Hi,
I'm trying to use WebForms 4.5 model binding.
Sale.cs
namespace SalesEFCodeFirst.Models
{
public class Sale
{
[Key]
public int ID { get; set; }
public int SoldUnits { get; set; }
public int Coefficient {get; set;}
public int ProductID { get; set; }
public virtual Product Product { get; set; }
[NotMapped]
public Single TotalAmount{
get
{
return Convert.ToSingle(Product.UnitPrice * SoldUnits * Coefficient);
//when saving throws : object reference not set to an instance of an object
}
// get{return Convert.ToSingle(SoldUnits * Coefficient);} // works when saving
}
}
}
Product.cs
public class Product
{
public int ProductID { get; set; }
public string Produ ...
Go to the complete details ...