AND == where, OR == ???
-
So if I write a statement like
var results = from items in collection
where from.SomeProperty == SomeValueDefinedEarlier
where from.SomeOtherProperty == SomeOtherValueDefinedEarlierThen the 2 where statements are an AND. How can an OR be done. Bellow is not what I expect the code to be, but gives a clear idea (I think) of why and what I am wanting to do.
var results = from items in collection
where from.SomeProperty == SomeValueDefinedEarlier
where from.SomeOtherProperty == SomeOtherValueDefinedEarlier
OR
where from.SomeProperty == SomeValueDefinedEarlier2
where from.SomeOtherProperty == SomeOtherValueDefinedEarlier2Thank you,
-
So if I write a statement like
var results = from items in collection
where from.SomeProperty == SomeValueDefinedEarlier
where from.SomeOtherProperty == SomeOtherValueDefinedEarlierThen the 2 where statements are an AND. How can an OR be done. Bellow is not what I expect the code to be, but gives a clear idea (I think) of why and what I am wanting to do.
var results = from items in collection
where from.SomeProperty == SomeValueDefinedEarlier
where from.SomeOtherProperty == SomeOtherValueDefinedEarlier
OR
where from.SomeProperty == SomeValueDefinedEarlier2
where from.SomeOtherProperty == SomeOtherValueDefinedEarlier2Thank you,
You can use boolean operators, like the && operator instead of the two 'where' clauses, and the | operator for an OR operation. For example, your first example would be:
var results = from items in collection
where from.SomeProperty == SomeValueDefinedEarlier
&& from.SomeOtherProperty == SomeOtherValueDefinedEarlierSecond example would be something like this:
var results = from items in collection
where ((from.SomeProperty == SomeValueDefinedEarlier)
&& (from.SomeOtherProperty == SomeOtherValueDefinedEarlier))
|| ((from.SomeProperty == SomeValueDefinedEarlier2)
&& (from.SomeOtherProperty == SomeOtherValueDefinedEarlier2))modified on Tuesday, May 26, 2009 6:25 AM
-
You can use boolean operators, like the && operator instead of the two 'where' clauses, and the | operator for an OR operation. For example, your first example would be:
var results = from items in collection
where from.SomeProperty == SomeValueDefinedEarlier
&& from.SomeOtherProperty == SomeOtherValueDefinedEarlierSecond example would be something like this:
var results = from items in collection
where ((from.SomeProperty == SomeValueDefinedEarlier)
&& (from.SomeOtherProperty == SomeOtherValueDefinedEarlier))
|| ((from.SomeProperty == SomeValueDefinedEarlier2)
&& (from.SomeOtherProperty == SomeOtherValueDefinedEarlier2))modified on Tuesday, May 26, 2009 6:25 AM
-
You can use boolean operators, like the && operator instead of the two 'where' clauses, and the | operator for an OR operation. For example, your first example would be:
var results = from items in collection
where from.SomeProperty == SomeValueDefinedEarlier
&& from.SomeOtherProperty == SomeOtherValueDefinedEarlierSecond example would be something like this:
var results = from items in collection
where ((from.SomeProperty == SomeValueDefinedEarlier)
&& (from.SomeOtherProperty == SomeOtherValueDefinedEarlier))
|| ((from.SomeProperty == SomeValueDefinedEarlier2)
&& (from.SomeOtherProperty == SomeOtherValueDefinedEarlier2))modified on Tuesday, May 26, 2009 6:25 AM