Veg*_*sen 0 c# linq entity-framework ef-code-first
我试图找到一种简单的方法来挑选一个客户服务代表来分配给一个给定的用户.我有以下型号:
public class Customer
{
public int Id { get; set; }
// SNIP
public virtual Representative Representative { get; set; }
public bool Active { get; set; }
}
public class Representative
{
public int Id { get; set; }
public int MaxActiveCustomers { get; set; }
// all the customers this representative has interacted with
public IEnumerable<Customer> Customers { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我试图找到目前Customers比MaxActiveCustomers建议少的代表.
我的尝试:
from r in Representatives
where r.MaxActiveCustomers > r.Customers.Count(c => c.Active)
select r
Run Code Online (Sandbox Code Playgroud)
这给了我以下例外:
NotSupportedException: The specified type member 'Customers' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
Run Code Online (Sandbox Code Playgroud)
这样做的正确方法是什么?
| 归档时间: |
|
| 查看次数: |
129 次 |
| 最近记录: |