相关疑难解决方法(0)

在LINQ语句中使用部分类属性

我试图找出做我认为很容易的最佳方法.我有一个名为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)

c# linq asp.net-mvc entity-framework asp.net-mvc-3

22
推荐指数
2
解决办法
8260
查看次数

标签 统计

asp.net-mvc ×1

asp.net-mvc-3 ×1

c# ×1

entity-framework ×1

linq ×1