Mas*_*ske 3 c# linq asp.net-mvc-5
我需要做一个过滤器,使用列表中包含的参数来请求数据.
if (filter.Sc.Count > 0)
socios.Where(s => filter.Sc.Contains(s.ScID));
Run Code Online (Sandbox Code Playgroud)
我尝试这种方式,但这不起作用,我也试过......
socios.Where( s => filter.Sc.All(f => f == s.ScID));
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做过滤器?
socios.Where(s => filter.Sc.Contains(s.ScID));
Run Code Online (Sandbox Code Playgroud)
返回已过滤的查询.它不会修改查询.您忽略了返回的值.你需要这样的东西:
socios = socios.Where(s => filter.Sc.Contains(s.ScID));
Run Code Online (Sandbox Code Playgroud)
但是根据socios确切语法的类型可能会有所不同.