首页 > 解决方案 > 从 ThenInclude 中排除空值

问题描述

我的EF上下文如下

_context.Offices
       .Where( x => x.ID == id )
            .Include( x => x.County)
               .ThenInclude( x => x.Employees)
                    .ThenInclude( s => s.Department)
                        .ThenInclude( m => m.DeptUser )
            .Include( x => x.XYZ);

我的问题是 DeptUser 可以为空。如何排除空项目?

标签: c#entity-framework

解决方案


推荐阅读