mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 23:13:42 +08:00
Delete Update Subquery Bug
This commit is contained in:
parent
735113ba5a
commit
d2ca0ee001
@ -105,6 +105,14 @@ namespace OrmTest.Demo
|
||||
}).Where(p => p.Id == 10000).ExecuteCommand();
|
||||
|
||||
|
||||
var t22= db.Updateable<Student>().UpdateColumns(p => new Student()
|
||||
{
|
||||
SchoolId = SqlFunc.Subqueryable<Student>().Where(s=>s.SchoolId==p.Id).Select(s=>s.Id)
|
||||
}).Where(p => p.Id == 10000).ExecuteCommand();
|
||||
|
||||
|
||||
var t23= db.Updateable<Student>(new Student() { })
|
||||
.Where(p => p.SchoolId == SqlFunc.Subqueryable<Student>().Where(s => s.SchoolId == p.Id).Select(s => s.Id)).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ namespace OrmTest.Demo
|
||||
var t5 = db.Deleteable<Student>().Where(it => it.Id > 1).Where(it => it.Id == 1).ExecuteCommand();
|
||||
|
||||
var t6 = db.Deleteable<Student>().AS("student").Where(it => it.Id > 1).Where(it => it.Id == 1).ExecuteCommandAsync();
|
||||
|
||||
|
||||
var t7 = db.Deleteable<Student>().Where(p => p.SchoolId == SqlFunc.Subqueryable<School>().Where(s => s.Id == p.SchoolId).Select(s => s.Id)).ExecuteCommand();
|
||||
t6.Wait();
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,11 @@ namespace SqlSugar
|
||||
public IDeleteable<T> Where(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
var expResult = DeleteBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle);
|
||||
DeleteBuilder.WhereInfos.Add(expResult.GetResultString());
|
||||
var whereString = expResult.GetResultString();
|
||||
if (expression.ToString().Contains("Subqueryable()")){
|
||||
whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".",this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
|
||||
}
|
||||
DeleteBuilder.WhereInfos.Add(whereString);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,12 @@ namespace SqlSugar
|
||||
public IUpdateable<T> Where(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
var expResult = UpdateBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle);
|
||||
UpdateBuilder.WhereValues.Add(expResult.GetResultString());
|
||||
var whereString = expResult.GetResultString();
|
||||
if (expression.ToString().Contains("Subqueryable()"))
|
||||
{
|
||||
whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
|
||||
}
|
||||
UpdateBuilder.WhereValues.Add(whereString);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user