Browse Source

Delete support navigate exp

pull/19/head
sunkaixuan 2 years ago
parent
commit
4e527a36df
  1. 8
      Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs
  2. 1
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/DeleteBuilder.cs
  3. 1
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionResult.cs
  4. 11
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs
  5. 4
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

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

@ -184,8 +184,12 @@ namespace SqlSugar
{
var expResult = DeleteBuilder.GetExpressionValue(expression, ResolveExpressType.WhereSingle);
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) + ".");
if (expression.ToString().Contains("Subqueryable()")) {
whereString = whereString.Replace(this.SqlBuilder.GetTranslationColumnName(expression.Parameters.First().Name) + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
}
else if (expResult.IsNavicate)
{
whereString = whereString.Replace(expression.Parameters.First().Name + ".", this.SqlBuilder.GetTranslationTableName(this.EntityInfo.DbTableName) + ".");
}
DeleteBuilder.WhereInfos.Add(whereString);
return this;

1
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/DeleteBuilder.cs

@ -154,6 +154,7 @@ namespace SqlSugar
{
resolveExpress.PgSqlIsAutoToLower = true;
}
resolveExpress.SugarContext = new ExpressionOutParameter() { Context = this.Context };
resolveExpress.MappingColumns = Context.MappingColumns;
resolveExpress.MappingTables = Context.MappingTables;
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;

1
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionResult.cs

@ -9,6 +9,7 @@ namespace SqlSugar
{
public bool IsLockCurrentParameter { get; set; }
public bool IsUpper { get; set; }
public bool IsNavicate { get; set; }
private ExpressionParameter _CurrentParameter;
public ExpressionParameter CurrentParameter
{

11
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs

@ -682,7 +682,16 @@ namespace SqlSugar
}
return result; ;
}
protected void SetNavigateResult()
{
if (this.Context != null)
{
if (this.Context.Result != null)
{
this.Context.Result.IsNavicate = true;
}
}
}
private string GetAsName(Expression item, object shortName, PropertyInfo property)
{
string asName;

4
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -248,6 +248,7 @@ namespace SqlSugar
if (nav.IsNavgate(express))
{
var sql = nav.GetSql();
SetNavigateResult();
this.Context.SingleTableNameSubqueryShortName = nav.ShorName;
base.AppendValue(parameter, isLeft, sql);
return;
@ -257,6 +258,7 @@ namespace SqlSugar
if (nav2.IsNavgate(express))
{
var sql = nav2.GetSql();
SetNavigateResult();
this.Context.SingleTableNameSubqueryShortName = nav2.shorName;
base.AppendValue(parameter, isLeft, sql);
return;
@ -293,6 +295,8 @@ namespace SqlSugar
}
}
private void NativeExtensionMethod(ExpressionParameter parameter, MethodCallExpression express, bool? isLeft, string name, List<MethodCallExpressionArgs> appendArgs = null)
{
var method = express.Method;

Loading…
Cancel
Save