我试图找出做我认为很容易的最佳方法.我有一个名为Line的数据库模型,它代表发票中的一行.
看起来大致如此:
public partial class Line
{
public Int32 Id { get; set; }
public Invoice Invoice { get; set; }
public String Name { get; set; }
public String Description { get; set; }
public Decimal Price { get; set; }
public Int32 Quantity { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
此类是从db模型生成的.
我有另一个类,增加了一个属性:
public partial class Line
{
public Decimal Total
{
get
{
return this.Price * this.Quantity
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,从我的客户控制器,我想做这样的事情:
var invoices = ( from c in _repository.Customers
where …Run Code Online (Sandbox Code Playgroud)