From 7f3cb6eb7ad3f29ebddc6a827723d77ce4883d31 Mon Sep 17 00:00:00 2001 From: sunkaixuna <610262374@qq.com> Date: Fri, 21 Jan 2022 10:26:15 +0800 Subject: [PATCH] Update core --- .../SqlBuilderProvider/QueryBuilder.cs | 19 ++++++++++++++++++- .../SqlSugar/Entities/SqlFilter.cs | 7 +++++-- .../SqlSeverTest/SqlSugar/SqlSugar.csproj | 4 ++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs index 6f8e64eb5..67112d4ce 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Abstract/SqlBuilderProvider/QueryBuilder.cs @@ -384,7 +384,24 @@ namespace SqlSugar sql = GetSql(exp, isSingle); sql = sql.Replace(itName, shortName); } - WhereInfos.Add(sql); + if (item.IsJoinQuery == false||isMain||isSingle|| isEasyJoin) + { + WhereInfos.Add(sql); + } + else + { + foreach (var joinInfo in this.JoinQueryInfos) + { + if (joinInfo.TableName.EqualCase(entityInfo.EntityName)|| joinInfo.TableName.EqualCase(entityInfo.DbTableName)) + { + if (sql.StartsWith(" WHERE ")) + { + sql = Regex.Replace(sql, $"^ WHERE ", " AND "); + } + joinInfo.JoinWhere=joinInfo.JoinWhere + sql; + } + } + } } private string GetSql(Expression exp, bool isSingle) diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/SqlFilter.cs b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/SqlFilter.cs index 0c76e155f..593e31c13 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/SqlFilter.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Entities/SqlFilter.cs @@ -27,16 +27,19 @@ namespace SqlSugar } private Expression exp { get; set; } private Type type { get; set; } - public TableFilterItem(Expression> expression) + public TableFilterItem(Expression> expression,bool isJoinOn=false) { exp = expression; type = typeof(T); + base.IsJoinQuery = isJoinOn; + this.IsJoinQuery = isJoinOn; } - public TableFilterItem(Type entityType,Expression expression) + public TableFilterItem(Type entityType,Expression expression, bool isJoinOn=false) { exp = expression; type = entityType; + IsJoinQuery = isJoinOn; } private new string FilterName { get; set; } diff --git a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugar.csproj b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugar.csproj index d18307091..26d93188b 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugar.csproj +++ b/Src/Asp.NetCore2/SqlSeverTest/SqlSugar/SqlSugar.csproj @@ -33,4 +33,8 @@ + + + +