Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.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# linq返回列表,其中包含找到的项_C#_Linq To Sql - Fatal编程技术网

C# linq返回列表,其中包含找到的项

C# linq返回列表,其中包含找到的项,c#,linq-to-sql,C#,Linq To Sql,使用linq:我有一个服务的对象列表 services[0] id=1, name="rental", ... services[1] id=2. name="buy", ... services[2] id=3. name="both", ... 等等 我已确定数组[]包含要从所选列表中检索的服务[]=1,3 foreach(var service in services.where(x=>x.id.Contains(selected)) 这就是我被卡住的地方。如何将conta

使用linq:我有一个服务的对象列表

services[0]
id=1, name="rental", ...

services[1]
id=2. name="buy", ...

services[2]
id=3. name="both", ...
等等

我已确定数组[]包含要从所选列表中检索的服务[]=1,3

 foreach(var service in services.where(x=>x.id.Contains(selected))
这就是我被卡住的地方。如何将contains添加到where子句中

生成错误:未找到包含运算符

请尝试在阵列上使用而不是
id

foreach(var service in services.where(x => selected.Contains(x.id))
尝试在阵列上使用而不是
id

foreach(var service in services.where(x => selected.Contains(x.id))