排除0排序
SQL
SELECT TOP (100) PERCENT *
FROM dbo.datatable
ORDER BY CASE WHEN sort <> 0 THEN sort ELSE 9999999999 END
Linq T-SQL
OrderByDescending(n => n.col1).ThenBy(n => n.col2).ThenBy(n => n.sort == 0 ? 9999999999 : n.sort )
Linq
var u = from u in db.users
orderby u.username == 100 ? 1 : 0 descending
select u;
文章標籤
全站熱搜
留言列表