Linq多重或带列表 [英] Linq Multiple OR with a list

查看:69
本文介绍了Linq多重或带列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用LINQ的C#项目中工作. 我想知道是否有可能用Linq创建一个多重OR子句",并以列表作为where的条目.

I'm currently working on a C# project where I'm using LINQ. I was wondering if it was possible to make a "multiple OR clause" with Linq with a list as an entry for the where.

我的意思是这样的:

var listofId;

var sqlQuery = from T in mytable 
               where T.ReferenceId = listOfId 
               select T;

关于如何做到这一点的任何想法?

Any idea about how to do that?

谢谢

推荐答案

您可以使用包含

listOfId.Contains(T.ReferenceId);

这篇关于Linq多重或带列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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