本文介绍了LINQ凡在收集条款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在寻找对谷歌,但没有找到任何东西,做的伎俩对我来说。
I've been looking on google but not finding anything that does the trick for me.
你也知道SQL有,其中x在(1,2 3)条款,它允许你要检查多个值。
我使用LINQ,但我似乎无法找到一块语法,做一样的上述声明。
as you know SQL has a "where x in (1,2,3)" clause which allows you to check against multiple values.I'm using linq but I can't seem to find a piece of syntax that does the same as the above statement.
我的收藏类别ID的(列表)一个我想检查
I have a collection of category id's (List) against which I would like to check
我找到了一个使用。载方法,但它甚至不建。
I found something that uses the .contains method but it doesn't even build.
推荐答案
您必须使用包含方法您的ID列表:
You have to use the Contains method on your id list:
var query = from t in db.Table
where idList.Contains(t.Id)
select t;
这篇关于LINQ凡在收集条款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!