Browse Source

Update exp to sql

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
33e3838528
  1. 1
      Src/Asp.Net/SqlServerTest/Demos/1_Query.cs
  2. 4
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

1
Src/Asp.Net/SqlServerTest/Demos/1_Query.cs

@ -452,6 +452,7 @@ namespace OrmTest.Demo
var test50 = db.Queryable<Student>().Where(it => it.CreateTime != null).Where(it => SqlFunc.ToDate(it.CreateTime).Year == SqlFunc.GetDate().Year).ToList(); var test50 = db.Queryable<Student>().Where(it => it.CreateTime != null).Where(it => SqlFunc.ToDate(it.CreateTime).Year == SqlFunc.GetDate().Year).ToList();
var test51 = db.Queryable<Student>().Select(it=>new { x= SqlFunc.ToDate(it.CreateTime).Year+"-" }).ToList(); var test51 = db.Queryable<Student>().Select(it=>new { x= SqlFunc.ToDate(it.CreateTime).Year+"-" }).ToList();
var test52 = db.Queryable<Student>().Select(it => SqlFunc.IsNull(it.CreateTime, SqlFunc.GetDate())).ToList(); var test52 = db.Queryable<Student>().Select(it => SqlFunc.IsNull(it.CreateTime, SqlFunc.GetDate())).ToList();
var test53 = db.Queryable<Student>().Select(it => SqlFunc.IsNull(it.CreateTime, SqlFunc.GetDate())).First();
} }
public static void Page() public static void Page()
{ {

4
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs

@ -407,6 +407,10 @@ namespace SqlSugar
} }
else 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; this.SelectCacheKey = result;
return result; return result;
} }

Loading…
Cancel
Save