1

我需要通过以下方式订购一些数据

DTO{
  id //nullable
  name // not nullable
}

demodata
entry1: Null / "TopItem"
entry2: 1    / "Numer1"
entry2: 3    / "Numer3"
entry2: 2    / "Numer2"

假设我需要将 id 为 null 的项目放在顶部,所有其他条目按列名排序

这可以用 LINQ2SQL 完成吗?

4

1 回答 1

1

尝试这样的事情:

from dto in context.DTO
orderby !dto.id.HasValue, dto.name
select dto
于 2012-10-17T16:09:21.020 回答