【问题标题】:Improve performance of Entity Framework Core EF with multi include statements使用多包含语句提高 Entity Framework Core EF 的性能
【发布时间】:2020-05-11 07:36:46
【问题描述】:

我一直在尝试提高 C# .NET Core 2.2 应用程序上多个包含语句的性能。关于如何改进此语句的任何建议?

private static void IncludeAssociatedEntities(ref IQueryable<Person> query)
{
    query = query.Include(p => p.Contact);
    query = query.Include(p => p.PersonAddressAssociations);
    query = query.Include(p => p.PersonCorePropertyAssociations);
    query = query.Include(p => p.PersonAssociations).ThenInclude(a =>  a.ParentPerson);
    query = query.Include(p => p.PersonPhones);
    query = query.Include(p => p.PersonOrganizationAssociations);
    query = query.Include(p => p.PersonProjectAssociations);
}

【问题讨论】:

标签: c# .net-core frameworks entity ef-core-2.2


【解决方案1】:

如果您查看生成的 SQL 代码和返回值,您将为此返回大量数据,

如果你得到想要的人然后用想要的数据填充它会更好。

但如果有办法改进它,那就太棒了……

您也可以通过优化存储过程然后调用它来使用 dapper

【讨论】:

    猜你喜欢
    • 2020-08-14
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-06
    相关资源
    最近更新 更多