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

后端 未结 3 1415
离开以前
离开以前 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 15:54

    I found the culprit. It's the SQL query generated by Entity Framework.
    I have a complicated Schema with a lot of many-to-many relationships.

    Entity Framework was generating a 32,000 line long SQL string :'(
    Now, I am changing my code to load the hierarchy manually for some part.

    Please let me know if anyone knows some good articles to read about Eager Loading and Many-to-Many relationships.

提交回复
热议问题