Is it possible to do a query that contains an if
? What I'd like to do is to select two certain columns based on the value of another column in the same table.
So if the value of column1
is 0
, I'd like to select custom开发者_JS百科1
and custom2
, if it's 1
, I'd like to select custom3
and custom4
.
var q = from c from MyTable
select new
{
item1 = (c.column1 == 0) ? custom1 : custom3,
item2 = (c.column1 == 0) ? custom2 : custom4
}
精彩评论