EF Core 3, optimize lots of Include/ThenInclude

前端 未结 4 900
予麋鹿
予麋鹿 2021-01-06 04:39

I have a query like this

return await _ctx.Activities
            .Include(a => a.Attributes)
            .Include(a => a.Roles)
            .Include(a         


        
4条回答
  •  -上瘾入骨i
    2021-01-06 05:32

    You can not. This is dimensional expansion SQL fights with. Ef 2.2 had what coudl be seen as an attempt to start with this, but they did not get it working and removed it.

    Your best chance is to load in multiple (possibly parallel) queries and then stitch the results together in memory. For EF there are libraries to do that - not sure they exist for EfCore. They run the queries as multiple queries.

提交回复
热议问题