Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.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# 无法使用内存中列表查找实体框架_C#_Sql_Linq_Entity Framework 4 - Fatal编程技术网

C# 无法使用内存中列表查找实体框架

C# 无法使用内存中列表查找实体框架,c#,sql,linq,entity-framework-4,C#,Sql,Linq,Entity Framework 4,我正在使用内存列表查找实体数据库,但出现以下错误: 无法创建“System.Collections.Generic.List”“1”类型的常量值。在此上下文中仅支持基本类型(“如Int32、String和Guid”) 我使用的代码是: dgv.DataSource = (from x in Helper.Ctx.Planner where myList.Contains(x.Customer) select x).Take(100); 我研究了这个问题,发现它建议我首先使用ToList()检索

我正在使用内存列表查找实体数据库,但出现以下错误:

无法创建“System.Collections.Generic.List”“1”类型的常量值。在此上下文中仅支持基本类型(“如Int32、String和Guid”)

我使用的代码是:

dgv.DataSource = (from x in Helper.Ctx.Planner where myList.Contains(x.Customer) select x).Take(100);
我研究了这个问题,发现它建议我首先使用ToList()检索所有内容,但数据库非常大,通过网络检索整个内容每次都需要几分钟

我使用的是EF4.1和VS2010


有什么解决办法吗

比较客户的Pk密钥而不是完整的对象

myList.Select(x => x.Id).Contains(x.Customer.Id)

您好,很抱歉,客户只是一个字符串字段(客户名称)而不是对象。似乎EF4不像Linq2Sql那样支持它,请查看此链接以了解可能的解决方法。