如果实体(集合父级)为null,如何在linq to sql中返回空的| null集合

oxosxuxt  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(171)

我有一个简单的linq到sql查询,它有一些表达式:

from entity in entities
let types = entity.SubEntity != null ? entity.SubEntity.Items.Select(x => x.Type) : null
select new { ... }

其中“types”是字符串列表。
最后我犯了个错误 An error occurred while preparing the command definition. See the inner exception for details. 我认为sql不能创建空集合或返回null。
什么是正确的解决方案?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题