使用Linq to Entities在單個查詢中選擇多個屬性。我有,如果然後在lambda表達式條件選擇這樣的屬性:Linq到實體如果查詢中有其他條件
Repository.Select(
x => Condition1 ? x.Property1 : x.Property2,
y => Condition2 ? y.Property1 : y.Property2,
z => .....);
生成的SQL是不必要的複雜。我想讓它不包括開始的其他條件。有沒有辦法讓它評估的條件,即只是
x=> x.Property1
生成sql之前?
只是表示作爲評估表達式的一個例子。所以也可以計算x => x.Property2 – Willis