From 66a4a410e662728a8b666f24ac5c44f3c7d70a15 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 7 Jul 2023 13:57:12 +0800 Subject: [PATCH] Update Deleteable by subquery --- .../SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index 3c9b33245..e474c7b0f 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -226,6 +226,11 @@ namespace SqlSugar var expResult = DeleteBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle); var whereString = expResult.GetResultString(); if (expression.ToString().Contains("Subqueryable()")) { + if (expression.Parameters.First().Type == typeof(T)) + { + var tableName = this.SqlBuilder.GetTranslationColumnName(this.EntityInfo.DbTableName); + whereString = whereString.Replace(tableName, $"( SELECT * FROM {tableName}) "); + } whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + "."); } else if (expResult.IsNavicate)