特定のユーザに割り当てる単一のカスタマーサービス担当者を選ぶ簡単な方法を見つけることを試みています。私は、次のモデルがあります:サブエンティティ数がn未満のエンティティを見つける
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; }
}
私は現在MaxActiveCustomers
よりCustomers
が示唆少ない持つ任意の代表者を見つけようとしています。
私の試み:
from r in Representatives
where r.MaxActiveCustomers > r.Customers.Count(c => c.Active)
select r
これは私に次の例外を与える:
NotSupportedException: The specified type member 'Customers' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
それを行うための正しい方法は何ですか?
私はCount(述語)はLinqではエンティティには作用しないと考えています。見てください[ここをクリック](http://msdn.microsoft.com/en-us/library/bb738550.aspx)(カウントの検索) – Reniuz
@ Reeniuz Countは正常に動作するはずです。 –