From 4b7d59adc80311d29867997464a8589681631c76 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 12 Jul 2023 17:37:42 +0800 Subject: [PATCH] Synchronization code --- .../Abstract/DeleteProvider/DeleteableProvider.cs | 9 +++++++-- .../Abstract/UpdateProvider/UpdateableProvider.cs | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index fd8eb821e..2154a92d4 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -227,12 +227,17 @@ namespace SqlSugar var expResult = DeleteBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle); var whereString = expResult.GetResultString(); if (expression.ToString().Contains("Subqueryable()")) { + var entityTableName = this.EntityInfo.DbTableName; + if (this.DeleteBuilder.AsName.HasValue()) + { + entityTableName = this.DeleteBuilder.AsName; + } if (ExpressionTool.GetParameters(expression).First().Type == typeof(T)) { - var tableName = this.SqlBuilder.GetTranslationColumnName(this.EntityInfo.DbTableName); + var tableName = this.SqlBuilder.GetTranslationColumnName(entityTableName); whereString = whereString.Replace(tableName, $"( SELECT * FROM {tableName}) "); } - whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + "."); + whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(entityTableName) + "."); } else if (expResult.IsNavicate) { diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index 8c23ab9a0..7d9e3541c 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -784,12 +784,17 @@ namespace SqlSugar var whereString = expResult.GetResultString(); if (expression.ToString().Contains("Subqueryable()")) { + var entityTableName = this.EntityInfo.DbTableName; + if (UpdateBuilder.TableName.HasValue()) + { + entityTableName = UpdateBuilder.TableName; + } if (ExpressionTool.GetParameters(expression).First().Type == typeof(T)) { - var tableName = this.SqlBuilder.GetTranslationColumnName(this.EntityInfo.DbTableName); + var tableName = this.SqlBuilder.GetTranslationColumnName(entityTableName); whereString = whereString.Replace(tableName, $"( SELECT * FROM {tableName}) "); } - whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + "."); + whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(entityTableName) + "."); } else if (expResult.IsNavicate) {