Rounding expressions in LINQ to SQL

If I want to generate a query (month(created) = 1 and year(created) = 2010) or (month(modified) = 1 and year(modified) = 2010) using linq, how would I do it?

I have o.Created.Value.Month == month && o.Created.Value.Year == year . If I do (o.Created.Value.Month == month && o.Created.Value.Year == year) || (o.Modified.Value.Month == month && o.Modified.Value.Year == year) (o.Created.Value.Month == month && o.Created.Value.Year == year) || (o.Modified.Value.Month == month && o.Modified.Value.Year == year) , should brackets be ignored?

+4
source share
1 answer

No, brackets will not be ignored by LINQ - they are important for specifying logic. They are effectively present in the expression tree, as a result you get the expression "OR" with two subexpressions, each of which is the expression "AND".

The query you specified should be in order - did you try it and check the received SQL?

+3
source

All Articles