码迷,mamicode.com
首页 > 编程语言 > 详细

OrderBy排序1,2,0,0,0,0

时间:2016-03-21 18:08:05      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

OrderBy排序1,2,0,0,0,0

lambda表达式排序
var
sql_BusinessInformation = db.BusinessInformation .OrderBy(d => d.sort == 0 ? int.MaxValue : d.sort).ThenByDescending(d => d.createtime)
生成的sql语句
.OrderBy(d => d.sort == 0 ? int.MaxValue : d.sort) 
转意为:

CASE WHEN (0 = [Extent1].[sort]) THEN 2147483647 ELSE [Extent1].[sort] END AS [C1]
SELECT 
    c1,
    [Project1].[id] AS [id], 
    [Project1].[sort] AS [sort], 
    [Project1].[createtime] AS [createtime]
    FROM ( SELECT 
        CASE WHEN (0 = [Extent1].[sort]) THEN 2147483647 ELSE [Extent1].[sort] END AS [C1], 
        [Extent1].[id] AS [id], 
        [Extent1].[createtime] AS [createtime]
        FROM [dbo].[BusinessInformation] AS [Extent1]
        WHERE 0 = [Extent1].[isExamine]
    )  AS [Project1]
    ORDER BY [Project1].[C1] ASC, [Project1].[createtime] DESC

 

OrderBy排序1,2,0,0,0,0

标签:

原文地址:http://www.cnblogs.com/OleRookie/p/5302617.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!