我如何轉換以下SQL從this文章:轉換SQL到LINQ到實體
select type, variety, price
from fruits
where price = (select min(price) from fruits as f where f.type = fruits.type)
我試着這樣說:
ctx.Fruits.
Where(f => f.Price == ctx.CreateObjectSet<Fruit>().
Where(f1 => f1.Type == f.Type).Min(f1 => f1.Price));
,但它並沒有因爲ctx.CreateObjectSet工作不能轉換爲SQL。
恥辱我!你是對的。我剛剛使用這個CreateObjectSet語法的連接,並沒有得到它不會在這裏工作 –
SiberianGuy