我收到此异常:
LINQ to Entities不支持指定的类型成员“付费”。仅支持初始化程序,实体成员和实体导航属性。
public ActionResult Index()
{
var debts = storeDB.Orders
.Where(o => o.Paid == false)
.OrderByDescending(o => o.DateCreated);
return View(debts);
}
我的模特班
public partial class Order
{
public bool Paid {
get {
return TotalPaid >= Total;
}
}
public decimal TotalPaid {
get {
return Payments.Sum(p => p.Amount);
}
}
Payments是一个包含字段金额的Related表,如果删除其中显示有关付款的正确信息的Where子句,该查询将起作用,任何提示代码有什么问题?
像建议的答案一样解决:
public ActionResult Index()
{
var debts = storeDB.Orders
.OrderByDescending(o => o.DateCreated)
.ToList()
.Where(o => o.Paid == false);
return View(debts);
}