【发布时间】:2011-03-05 12:21:46
【问题描述】:
/// <summary>
/// Find all of the Areas that are Parents without children Areas.
/// </summary>
/// <returns>IQueryable object full of Areas.</returns>
public IQueryable FindParentAreas()
{
return db.Areas.SelectMany(x => x.ParentAreaID == null);
}
我想返回作为父区域的区域对象的集合,这意味着它们在 ParentAreaID 字段(在我的数据库中)中具有空值。
似乎我不能将它与 null 进行比较,因为 C# 中的 null 可能意味着 Microsoft SQL Server 中的其他内容。
有什么指导吗?我什至应该使用 SelectMany 吗?
【问题讨论】:
标签: c# linq-to-sql tsql