Filtering On ThenInclude, with EntityFrameworkPlus IncludeFilter

前端 未结 1 1357
执笔经年
执笔经年 2021-01-23 06:55

I am trying to filter three child levels down and find only child elements where PropertyMailingAddress.Status== True.

How do I convert filter three levels down and con

相关标签:
1条回答
  • 2021-01-23 07:44

    You cannot mixte Include with IncludeFilter.

    In EF Core, the IncludeFilter should automatically add all paths.

    We don't have the class definition so it makes it hard to know exactly the relationship but the query should look like this:

    var result = await db.Property.IncludeFilter(pm => pm.PropertyParty
                                    .Select(x => x.Party)
                                    .SelectMany(x => x.PartyMailingAddress)
                                    .SelectMany(x => x.PropertyMailingAddress.Where(z => z.Status == true)).ToListAsync();
    

    The filtering is done in the database. So be careful with EF Core 2.x, as their have a client side evaluation they removed in EF Core 3.x which was causing some problem.

    If you need more help, just provide a runnable solution in our issue tracker: https://github.com/zzzprojects/EntityFramework-Plus/issues

    0 讨论(0)
提交回复
热议问题