EF Where(x => x.ColumnVal == 1) vs FirstOrDefault(x => x.Column == 1)

后端 未结 3 1432
离开以前
离开以前 2021-01-05 15:10

I had a LINQ query that loads a hierarchy of objects like the following.

Query #1

var result = db.Orders
               .Include(\"C         


        
3条回答
  •  迷失自我
    2021-01-05 16:02

    I think best would be to use ...Where(condition).Take(1).FirstOrDefault() because Take(1) can be easily translated to SQL as a TOP clause. Anybody with me?

提交回复
热议问题