From 44dbbea544cc6ed5ef62dcf1f94a2e1bfbbe3ab1 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 7 Jul 2023 15:47:08 +0800 Subject: [PATCH] Synchronization code --- .../DeleteProvider/DeleteableProvider.cs | 21 ++++++++++--------- .../SqlBuilderProvider/DeleteBuilder.cs | 5 +++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index e9b0ed5a0..9512eaeb4 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -74,15 +74,16 @@ namespace SqlSugar public IDeleteable AS(string tableName) { if (tableName == null) return this; - var entityName = typeof(T).Name; - IsAs = true; - OldMappingTableList = this.Context.MappingTables; - this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables); - if (this.Context.MappingTables.Any(it => it.EntityName == entityName)) - { - this.Context.MappingTables.Add(this.Context.MappingTables.First(it => it.EntityName == entityName).DbTableName, tableName); - } - this.Context.MappingTables.Add(entityName, tableName); + //var entityName = typeof(T).Name; + //IsAs = true; + //OldMappingTableList = this.Context.MappingTables; + //this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables); + //if (this.Context.MappingTables.Any(it => it.EntityName == entityName)) + //{ + // this.Context.MappingTables.Add(this.Context.MappingTables.First(it => it.EntityName == entityName).DbTableName, tableName); + //} + //this.Context.MappingTables.Add(entityName, tableName); + this.DeleteBuilder.AsName = tableName; return this; ; } public IDeleteable EnableDiffLogEventIF(bool isEnableDiffLogEvent, object businessData = null) @@ -628,7 +629,7 @@ namespace SqlSugar { List result = new List(); var whereSql = Regex.Replace(sql, ".* WHERE ", "", RegexOptions.Singleline); - var dt = this.Context.Queryable().Filter(null, true).Where(whereSql).AddParameters(parameters).ToDataTable(); + var dt = this.Context.Queryable().AS(this.DeleteBuilder.AsName).Filter(null, true).Where(whereSql).AddParameters(parameters).ToDataTable(); if (dt.Rows != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/SqlBuilderProvider/DeleteBuilder.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/SqlBuilderProvider/DeleteBuilder.cs index 1ea3ce445..4c14d3f64 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/SqlBuilderProvider/DeleteBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/SqlBuilderProvider/DeleteBuilder.cs @@ -19,6 +19,7 @@ namespace SqlSugar public StringBuilder sql { get; set; } public ISqlBuilder Builder { get; set; } public string TableWithString { get; set; } + public string AsName { get; set; } public virtual List WhereInfos { get @@ -83,6 +84,10 @@ namespace SqlSugar get { var result = Builder.GetTranslationTableName(EntityInfo.EntityName); + if (AsName.HasValue()) + { + result = Builder.GetTranslationColumnName(AsName); + } result += UtilConstants.Space; if (this.TableWithString.HasValue()) {