linq查询值检索 [英] linq query values retrieving

查看:73
本文介绍了linq查询值检索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何在一个查询中使用值数组,以及如何在同一Action方法中在其他查询的where子句中使用这些值.


how to use an array of values in one query and use those values in the where clause of other query in the same Action method.

推荐答案

您是否尝试过转换数组转换为通用列表,并在where子句中使用该列表?

have you tried to convert the array to a generic list, and use that list in the where clause?

List<int> lst = new List<int>();
lst.Add(1);
lst.Add(2);
lst.Add(3);

var processes = from dtProcs in Process.GetProcesses()
             where (lst.Contains(dtProcs.Id))
             select dtProcs;



这应该可以解决问题.



This should do the trick.


这篇关于linq查询值检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆