Linq to sql Linq2SQL排序器

Linq to sql Linq2SQL排序器,linq-to-sql,sql-order-by,Linq To Sql,Sql Order By,我需要按以下方式订购一些数据 DTO{ id //nullable name // not nullable } demodata entry1: Null / "TopItem" entry2: 1 / "Numer1" entry2: 3 / "Numer3" entry2: 2 / "Numer2" 假设我需要将id为null的项放在顶部,并按列名对所有其他项进行排序 使用LINQ2SQL可以做到这一点吗?尝试以下方法: from dto in context

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

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

demodata
entry1: Null / "TopItem"
entry2: 1    / "Numer1"
entry2: 3    / "Numer3"
entry2: 2    / "Numer2"
假设我需要将id为null的项放在顶部,并按列名对所有其他项进行排序


使用LINQ2SQL可以做到这一点吗?

尝试以下方法:

from dto in context.DTO
orderby !dto.id.HasValue, dto.name
select dto

试着这样做:

from dto in context.DTO
orderby !dto.id.HasValue, dto.name
select dto