If I want to generate the query (month(created) = 1 and year(created) = 2010) or (month(modified) = 1 and year(modified) = 2010)
with linq, how would I go about it?
I have o.Created.Value.Month == month && o.Created.Value.Year == year
. If I do (o.Creat开发者_运维技巧ed.Value.Month == month && o.Created.Value.Year == year) || (o.Modified.Value.Month == month && o.Modified.Value.Year == year)
wouldn't the parenthesis just be ignored?
No, the parentheses won't be ignored by LINQ - they're important to indicate the logic. They're effectively present in the expression tree, in that you'll end up with an "OR" expression with two subexpressions each of which is an "AND" expression.
The query you've given should be fine - have you tried it, and checked the resulting SQL?
精彩评论