Multiple Includes() in EF Core

后端 未结 8 2172
傲寒
傲寒 2020-12-08 08:07

I have an extension method that lets you generically include data in EF:

public static IQueryable IncludeMultiple(this IQueryable          


        
8条回答
  •  孤城傲影
    2020-12-08 08:51

    Ofcourse there is,

    you could traverse the Expression tree of original params, and any nested includes, add them as

     .Include(entity => entity.NavigationProperty)
     .ThenInclude(navigationProperty.NestedNavigationProperty)
    

    But its not trivial, but definitely very doable, please share if you do, as it can defintiely be reused!

提交回复
热议问题