From 33e383852897002b211dc27b2b391e7ff1fcd064 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 15 Apr 2019 21:54:42 +0800 Subject: [PATCH] Update exp to sql --- Src/Asp.Net/SqlServerTest/Demos/1_Query.cs | 1 + .../SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Src/Asp.Net/SqlServerTest/Demos/1_Query.cs b/Src/Asp.Net/SqlServerTest/Demos/1_Query.cs index 1117c7d6d..4002a57f7 100644 --- a/Src/Asp.Net/SqlServerTest/Demos/1_Query.cs +++ b/Src/Asp.Net/SqlServerTest/Demos/1_Query.cs @@ -452,6 +452,7 @@ namespace OrmTest.Demo var test50 = db.Queryable().Where(it => it.CreateTime != null).Where(it => SqlFunc.ToDate(it.CreateTime).Year == SqlFunc.GetDate().Year).ToList(); var test51 = db.Queryable().Select(it=>new { x= SqlFunc.ToDate(it.CreateTime).Year+"-" }).ToList(); var test52 = db.Queryable().Select(it => SqlFunc.IsNull(it.CreateTime, SqlFunc.GetDate())).ToList(); + var test53 = db.Queryable().Select(it => SqlFunc.IsNull(it.CreateTime, SqlFunc.GetDate())).First(); } public static void Page() { diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs index 1a4a31a46..9a7a9a15f 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs @@ -407,6 +407,10 @@ namespace SqlSugar } else { + if (expression is LambdaExpression && (expression as LambdaExpression).Body is MethodCallExpression&&this.Context.CurrentConnectionConfig.DbType==DbType.SqlServer&&this.OrderByValue.HasValue()) + { + result = result + " AS columnName"; + } this.SelectCacheKey = result; return result; }