Browse Source

Update exp to sql

pull/30/head
sunkaixuan 2 years ago
parent
commit
683b8f0e9b
  1. 1
      Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs
  2. 1
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
  3. 6
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs
  4. 6
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs

1
Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs

@ -209,6 +209,7 @@ namespace SqlSugar
else if (expResult.IsNavicate)
{
whereString = whereString.Replace(expression.Parameters.First().Name + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
}
DeleteBuilder.WhereInfos.Add(whereString);
return this;

1
Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

@ -572,6 +572,7 @@ namespace SqlSugar
else if (expResult.IsNavicate)
{
whereString = whereString.Replace(expression.Parameters.First().Name + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
}
UpdateBuilder.WhereValues.Add(whereString);
return this;

6
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs

@ -85,7 +85,11 @@ namespace SqlSugar
}
var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
if (this.Context.JoinIndex == 0)
if (this.Context.JoinIndex == 0 && result.Contains(" FROM "))
{
this.Context.CurrentShortName = selfParameterName;
}
else if (this.Context.JoinIndex == 0)
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
return result;
}

6
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs

@ -87,7 +87,11 @@ namespace SqlSugar
}
var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
if (this.Context.JoinIndex == 0)
if (this.Context.JoinIndex == 0&&result.Contains(" FROM "))
{
this.Context.CurrentShortName= selfParameterName;
}
else if (this.Context.JoinIndex == 0)
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
if (!string.IsNullOrEmpty(selfParameterName) && this.Context.IsSingle&& this.Context.JoinIndex == 0)
{

Loading…
Cancel
Save