我使用延迟加载,但是在我的“计算”属性中,当我尝试访问相关属性时,Amount有'System.NullReferenceException' 任何想法?
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();