0

I using lazy loading, but in my "calculated" property Amount have 'System.NullReferenceException' when i try to access to related property any idea?

public class SalesLine
{
    public int LineNo { get; set; }
    public int DocumentNo { get; set; }
    public int ItemId { get; set; }
    public virtual Item Item { get; set; }
    public int Quantity { get; set; }
    public decimal Amount { get { return Quantity * Item.UnitPrice; } set { } }
}
public class Item
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal UnitCost { get; set; }
    public decimal UnitPrice { get; set; }
}

var lines = context.SalesLine.ToList();

0 Answers0