From 575a9e31b51bb9f9ea037aa2bdd5084e62ee49ec Mon Sep 17 00:00:00 2001 From: skx <610262374@qq.com> Date: Sat, 7 Nov 2020 16:50:42 +0800 Subject: [PATCH] Update exp to sql --- .../SqlServerTest/SqlServerTest.csproj | 1 + .../SqlServerTest/_OldTest/BugTest/Bug3t.cs | 46 +++++++++++++++++++ .../ExpressionsToSql/ExpressionContext.cs | 2 + 3 files changed, 49 insertions(+) create mode 100644 Src/Asp.Net/SqlServerTest/_OldTest/BugTest/Bug3t.cs diff --git a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj index 7895aabb9..deba7e3e9 100644 --- a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj +++ b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj @@ -92,6 +92,7 @@ + diff --git a/Src/Asp.Net/SqlServerTest/_OldTest/BugTest/Bug3t.cs b/Src/Asp.Net/SqlServerTest/_OldTest/BugTest/Bug3t.cs new file mode 100644 index 000000000..44de17045 --- /dev/null +++ b/Src/Asp.Net/SqlServerTest/_OldTest/BugTest/Bug3t.cs @@ -0,0 +1,46 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OrmTest.Test +{ + public class BugTest + { + public static void Init() + { + SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig() + { + ConnectionString = Config.ConnectionString, + DbType = DbType.SqlServer, + IsAutoCloseConnection = true, + //MoreSettings = new ConnMoreSettings() + //{ + // PgSqlIsAutoToLower = true //我们这里需要设置为false + //}, + InitKeyType = InitKeyType.Attribute, + }); + //调式代码 用来打印SQL + Db.Aop.OnLogExecuting = (sql, pars) => + { + Console.WriteLine(sql); + }; + + var list2 = Db.Queryable((o, i, c) => new JoinQueryInfos( + JoinType.Left, o.Id == i.OrderId, + JoinType.Left, c.Id == o.CustomId + )) + .Select((o,i,c) => new Order + { + Id=SqlFunc.IsNull( + SqlFunc.Subqueryable().Where(f=>f.CreateTime>Convert.ToDateTime( o.CreateTime.AddDays(-1)) ).Select(f => f.Id) + ,-1) + }).ToList(); + } + } + + +} diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ExpressionContext.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ExpressionContext.cs index 40fc5a367..e9e99494f 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ExpressionContext.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ExpressionContext.cs @@ -127,6 +127,7 @@ namespace SqlSugar copyContext.RefreshMapping = this.RefreshMapping; copyContext.ParameterIndex = this.ParameterIndex; copyContext.PgSqlIsAutoToLower = this.PgSqlIsAutoToLower; + copyContext.IsSingle = this.IsSingle; return copyContext; } public ExpressionContext GetCopyContextWithMapping() @@ -141,6 +142,7 @@ namespace SqlSugar copyContext.InitMappingInfo = this.InitMappingInfo; copyContext.RefreshMapping = this.RefreshMapping; copyContext.PgSqlIsAutoToLower = this.PgSqlIsAutoToLower; + copyContext.IsSingle = this.IsSingle; return copyContext; } #endregion