.net-core - EF Core 嵌套实体处理
问题描述
我有带有 EF Core 的 .NET Core 应用程序。
我需要获取 Thread 对象的列表,但我还需要嵌套表中的一个属性,它是dbo.Container.Description
我愿意:
var threads = this.context.Threads
.Include(x => x.ThreadsPosts)
.ThenInclude(x => x.Post)
.ThenInclude(x => x.CreatedByUser)
.ThenInclude(x => x.UserProfile)
.ThenInclude(x => x.Container);
然后我通过线程循环:
var description = thread.ThreadsPosts.Last().Post.CreatedByUser.UserProfile.Container.Description;
但据我了解,我从所有嵌套表的所有列中获取数据?
那么有没有性能问题呢?
也许有一种方法可以减少列数?
如何正确编写此结构?
解决方案
推荐阅读
- ag-grid - 如何控制 ag-grid 的侧面板,所以我只启用分组
- javascript - owl-date-time : 事件没有在日期时间选择时触发?
- html - IE11 中带有页眉、页脚和内容部分的布局
- reactjs - 在这种情况下,可以忽略 react key prop 警告
- image - 如何在 keras 中自定义 ImageDataGenerator 的 .flow 方法(在图像处理中)
- php - PDO 插入 foreach
- c# - 转换 IEnumerable 时的 Sql 超时
列出 在 C# 实体框架中 - network-programming - 生成数据包中所有位所需的时间......为什么数据包大小除以数据大小?
- ios - AVPlayer 没有从子域的 url 加载视频
- json - '_InternalLinkedHashMap
' 不是类型 'Iterable 的子类型 ' 在类型转换中