LINQ: select <contition> OR <condition>

Pseudocode:

SELECT * FROM 'table' WHERE ('date' <today) OR ('visible' = false)

How do you do OR in Linq?

+3
source share
2 answers

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

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

If you prefer the syntax of the method:

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

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

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

Source: https://habr.com/ru/post/1770951/


All Articles