EF Core 1.0

编程入门 行业动态 更新时间:2024-10-09 06:29:34
本文介绍了EF Core 1.0-Include()生成多个查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用EF 7.0.0-rc1-final。

I am using EF 7.0.0-rc1-final.

以下语句在服务器上生成多个查询。 这是正常现象还是我缺少什么?

The following statement generates multiple queries on the server. Is this normal or I am missing something ?

Group myGroup = dbContext_ .Set<Group>() .Include(x => x.GroupRoles) .ThenInclude(x => x.Role) .FirstOrDefault(x => x.Name == "Approver");

我在服务器上看到两个独立的查询:

I see two separate queries executed on the server:

这是标准的多对多方案。为什么是第一个查询?

It's a standard many-to-many scenario. Why is the first query ?

谢谢

推荐答案

是的

EF7生成多个查询以避免多次返回相同的数据。

EF7 generates multiple queries to avoid returning the same data multiple times.

以下是有关EF6 Include的精彩文章,以了解为什么EF7需要进行此更改:实体框架的陷阱,包括

Here is a great post about EF6 Include to understand why this change was required for EF7: Entity Framework pitfalls, include

更多推荐

EF Core 1.0

本文发布于:2023-11-15 06:24:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1591936.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:EF   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!