开发者

Order by in Linq

开发者 https://www.devze.com 2023-01-20 03:17 出处:网络
how can i 开发者_高级运维show null or empty fieldsin last by apply Orderby: here is my code. Var movies = _db.Movies.Orderby(c => c.Category).ThenBy(n => n.Name)

how can i 开发者_高级运维show null or empty fields in last by apply Orderby:

here is my code.

Var movies = _db.Movies.Orderby(c => c.Category).ThenBy(n => n.Name)


If I understand your question correctly:

Var movies = _db.Movies
    .OrderBy(c => c.Category==null?1:0)
    .Thenby(c => c.Category).ThenBy(n => n.Name)
0

精彩评论

暂无评论...
验证码 换一张
取 消