Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.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# 使用Contains作为';在';Silverlight中实体框架中使用LINQ的cluase_C#_Silverlight_Entity Framework 4.1 - Fatal编程技术网

C# 使用Contains作为';在';Silverlight中实体框架中使用LINQ的cluase

C# 使用Contains作为';在';Silverlight中实体框架中使用LINQ的cluase,c#,silverlight,entity-framework-4.1,C#,Silverlight,Entity Framework 4.1,我试图返回一个项目列表(vwProposedMigrations),其中vwProposedMigrations的DeptCode位于用户授权管理的部门列表中 结果包含部门代码字符串的列表。这些已通过先前的entityQuery加载并正确返回 var result = (from r in wtps.Schedule_Owner_DeptCode_Mappings select r.DeptCode).ToList(); var data = wtps.GetVwProposedMigratio

我试图返回一个项目列表(vwProposedMigrations),其中vwProposedMigrations的DeptCode位于用户授权管理的部门列表中

结果包含部门代码字符串的列表。这些已通过先前的entityQuery加载并正确返回

var result = (from r in wtps.Schedule_Owner_DeptCode_Mappings select r.DeptCode).ToList();
var data = wtps.GetVwProposedMigrationsQuery().Where(x=>result.Contains(x.DepartmentCode));
LoadOperation dataLoad = wtps.Load<vwProposedMigration>(data);
dataLoad.Completed += new EventHandler(LoadvwProposedMigrationsOperation_Completed);
var result=(从wtps.Schedule\u Owner\u DeptCode\u映射中的r选择r.DeptCode);
var data=wtps.GetVwProposedMigrationsQuery()。其中(x=>result.Contains(x.DepartmentCode));
LoadOperation dataLoad=wtps.Load(数据);
dataLoad.Completed+=新的事件处理程序(LoadvwProposedMigrationsOperation\u Completed);
但是收到这个错误:

“System.Collections.Generic.List
1[System.String]类型的值”
无法作为查询的一部分序列化。
“System.Collections.Generic.List
1[System.String]”不是受支持的选项 类型

我曾尝试使用
ObservableCollection
字符串[]
来保存部门代码列表,但同样的问题也出现了。我见过很多使用Contains的示例,但是这些示例在数据加载后对其进行操作,而不是限制初始查询

我试图避免加载vwProposedMigrations的整个结果集,因为它大约有38000行,所以我的目标是将查询仅限于用户感兴趣的那些行

谢谢 Mick检查一下:

  var result = (from r in wtps.Schedule_Owner_DeptCode_Mappings select r.DeptCode);
  var data = wtps.GetVwProposedMigrationsQuery().Where(x=>result.Contains(x.DepartmentCode));
请检查这个

var data = wtps.GetVwProposedMIgrationsQuery().Where(x=>result.Any(z=>z.DepartmentCode == x.DepartmentCode))

什么是底层数据库?(SQL?Oracle?等)以及
wtps.GetVwProposedMigrationsQuery()返回的类型是什么?DB是MS-SQL。wtps是我的实体框架DomainContext(WTPSDomainContext)的一个实例。返回类型为EntityQuerytry,在
的Where(..)
前面添加
.AsQueryable()
。这是一个很长的机会,但你可以尝试:)我只是在文档中查找,永远不能使用包含:(嗯。糟糕的时候。我必须想出一个狡猾的解决办法。我单独找到了这个,但这是我最终使用的方法。谢谢你的回答