This is a very simple LINQ and/or question.
In the following query excerpt, my intention is to obtain records which match any of the three conditions below.
Is my logic correct or is there a better way to phrase this?
- (t2.Username == userName) && (viewMode == 1)
- (t1.Owner == userName) && (viewMode == 1)
- (viewMode == 2)
Query excerpt
where
((t2.Username == userName) && (viewMode == 1)) ||
((t1.Owner == userName) && (viewMode == 1)) ||
((viewMode == 2))
You’re logic looks fine, you could of course do it slightly differently:
Whichever looks better to your eyes I guess!