[英]Improve performance of Entity Framework Core EF with multi include statements
我一直在嘗試提高 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);
}
如果您查看生成的 SQL 代碼和返回值,您將為此返回大量數據,
如果你得到想要的人然后用想要的數據填充它會好得多。
但如果有辦法改善這一點,那將是驚人的......
您也可以通過制作優化的存儲過程然后調用它來使用 dapper
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.