Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 查找子实体少于n个的实体_C#_Linq_Entity Framework_Ef Code First - Fatal编程技术网

C# 查找子实体少于n个的实体

C# 查找子实体少于n个的实体,c#,linq,entity-framework,ef-code-first,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 { publ

我正试图找到一种简单的方法来挑选一个客户服务代表分配给给定的用户。我有以下型号:

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; }
}
这给了我以下例外情况:

NotSupportedException: The specified type member 'Customers' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

<> P> >你已经定义了<代码>客户>代码>类型>代码> iQueabue<代码>,EF不被认为是模型的一部分。将类型更改为<代码> ICOLSECTION/COD> .< /P> < P>您已经定义了<代码>客户>代码>类型<代码> iQueaby,EF不被认为是模型的一部分。将类型更改为
ICollection

,此外,我认为Count(谓词)在Linq to实体中不起作用。看看(搜索count)@Reniuz count应该可以正常工作。此外,我认为count(谓词)在Linq to实体中不起作用。看一看(搜索count)@Reniuz count应该很好用。我知道它一定很简单。这就是我在别人审阅我的代码之前发布到SO的结果…:)我知道这一定很简单。这就是我在别人审阅我的代码之前发布到SO的结果…:)
NotSupportedException: The specified type member 'Customers' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.