开发者

Multiple Conditional statements in LINQ

Is this possible to do in LINQ, this wouldn;t compile however this is the result am trying to achieve.

I know I can filter this prior to union statement, curious to know if this is supported or not.

var _tickers = (from _position in positions_
                      where _position.Ticker_PositionQuote.PropertyValue != string.Empty
                      select _position.Ticker_PositionQuote.PropertyValue)
        .Union(
          from _position in positions_
          where _position.AssetClassLevel2.PropertyValue.ToUpper() == "EQUITY OPTIONS"
          and _position.Ticker_PositionUnderlyerQuote.PropertyValue != str开发者_开发百科ing.Empty
          select _position.Ticker_PositionUnderlyerQuote.PropertyValue);

Thanks,

Raul Dsouza


If I understand your question correctly, you are looking for a way to implement this "and" statement. Please correct me if I am wrong.

To get the result of

from item in collection
where condition1 "and" condition2

you can use either

from item in collection
where condition1 && condition2

or

from item in collection
where condition1 
where condition2

The first method will probably be faster.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜