Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.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

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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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# 中SQL的LINQ/Lambda等价物_C#_Linq_Lambda - Fatal编程技术网

C# 中SQL的LINQ/Lambda等价物

C# 中SQL的LINQ/Lambda等价物,c#,linq,lambda,C#,Linq,Lambda,我有一个IEnumerable,它有一个ID为的对象列表。我想选择ID为1、2、7、8、9、10和11的对象。我不知道等效SQL语句select*的LINQ/Lambda等效项,其中id在1、2、7、8、9、10、11中 我试过这样的方法: var movieratings = new int[] {1, 2, 7, 8, 9, 10, 11}; list.ratings= list.ratings.Select(x => movieratings.Contains(x.Value));

我有一个IEnumerable,它有一个ID为的对象列表。我想选择ID为1、2、7、8、9、10和11的对象。我不知道等效SQL语句select*的LINQ/Lambda等效项,其中id在1、2、7、8、9、10、11中

我试过这样的方法:

var movieratings = new int[] {1, 2, 7, 8, 9, 10, 11};
list.ratings= list.ratings.Select(x => movieratings.Contains(x.Value));

但这给了我一个编译错误,比如说不能从用法推断类型参数

如果要进行筛选,则需要在where子句而不是select子句中进行筛选

var movieratings = new int[] {1, 2, 7, 8, 9, 10, 11};
list.ratings = list.ratings.Where(x => movieratings.Contains(x.Value));