Browse Source

BUG: db.Updateable<Custom>()

.AS("order")
             .SetColumns(it=>it.Name=="a")
             .Where(it => SqlFunc.Subqueryable<Custom>().AS("order").Where(s => s.Id == it.Id).NotAny()).ExecuteCommand();
pull/40/head
sunkaixuan 1 year ago
parent
commit
1c3b081bcf
  1. 9
      Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs
  2. 9
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

9
Src/Asp.Net/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)
{

9
Src/Asp.Net/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)
{

Loading…
Cancel
Save