开发者

LINQ: Select <contition> OR <condition>

Pseudo code:

SELECT * FROM 'table' WHERE ('date' < today)开发者_StackOverflow OR ('visible' = false)

How do you do OR in Linq?


You just use the language specific OR condition. In C#:

var results = from row in table
              where row.date < today || row.visible == false
              select row;

If you prefer the method syntax:

var results = table.Where(row => row.date < today || row.visible == false);


Reed nailed the C# one, here is the VB.Net equivalent

Dim results = _
  From row In table _
  Where row.Date < today OrElse row.Visible = False 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜