DISABILITARE ADBLOCK

ADBlock sta bloccando alcuni contenuti del sito

ADBlock errore
5 Characters minimum

So if I write a statement like

<br />var results = from items in collection<br />                     where from.SomeProperty == SomeValueDefinedEarlier<br />                     where from.SomeOtherProperty == SomeOtherValueDefinedEarlier<br />


Then 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.

<br />var results = from items in collection<br />                     where from.SomeProperty == SomeValueDefinedEarlier<br />                     where from.SomeOtherProperty == SomeOtherValueDefinedEarlier<br />                     OR<br />                     where from.SomeProperty == SomeValueDefinedEarlier2<br />                     where from.SomeOtherProperty == SomeOtherValueDefinedEarlier2<br /><br />


Thank you,

Leggi tutto

Solution

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:

<br />var results = from items in collection<br />                     where from.SomeProperty == SomeValueDefinedEarlier<br />                     && from.SomeOtherProperty == SomeOtherValueDefinedEarlier<br />

Second example would be something like this:
<br />var results = from items in collection<br />                     where ((from.SomeProperty == SomeValueDefinedEarlier)<br />                     && (from.SomeOtherProperty == SomeOtherValueDefinedEarlier))<br />                     || ((from.SomeProperty == SomeValueDefinedEarlier2)<br />                     && (from.SomeOtherProperty == SomeOtherValueDefinedEarlier2))<br />


modified on Tuesday, May 26, 2009 6:25 AM

USEFUL SOURCES

CodeProject
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow