Browse Source

Synchronization code

pull/26/MERGE
sunkaixuan 2 years ago
parent
commit
48b1b68cc2
  1. 8
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs
  2. 5
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubInnerJoin.cs
  3. 5
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubLeftJoin.cs
  4. 8
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs

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

@ -41,7 +41,13 @@ namespace SqlSugar
{ {
var exp = expression as MethodCallExpression; var exp = expression as MethodCallExpression;
var argExp = exp.Arguments[0]; var argExp = exp.Arguments[0];
var result = "AND " + SubTools.GetMethodValue(this.Context, argExp, ResolveExpressType.WhereMultiple); var copyContext = this.Context;
if (this.Context.JoinIndex > 0)
{
copyContext = this.Context.GetCopyContextWithMapping();
copyContext.IsSingle = false;
}
var result = "AND " + SubTools.GetMethodValue(copyContext, argExp, ResolveExpressType.WhereMultiple);
var regex = @"^AND (\@Const\d+) $"; var regex = @"^AND (\@Const\d+) $";

5
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubInnerJoin.cs

@ -45,7 +45,10 @@ namespace SqlSugar
var argExp = exp.Arguments[0]; var argExp = exp.Arguments[0];
var name =this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters[0].Name); var name =this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters[0].Name);
var parameter = (argExp as LambdaExpression).Parameters.Last(); var parameter = (argExp as LambdaExpression).Parameters.Last();
Context.InitMappingInfo(parameter.Type); foreach (var item in (argExp as LambdaExpression).Parameters)
{
Context.InitMappingInfo(item.Type);
}
this.Context.RefreshMapping(); this.Context.RefreshMapping();
var tableName= Context.GetTranslationTableName(parameter.Type.Name, true); var tableName= Context.GetTranslationTableName(parameter.Type.Name, true);
var joinString =string.Format(" {2} INNER JOIN {1} {0} ", var joinString =string.Format(" {2} INNER JOIN {1} {0} ",

5
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubLeftJoin.cs

@ -45,7 +45,10 @@ namespace SqlSugar
var argExp = exp.Arguments[0]; var argExp = exp.Arguments[0];
var name =this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters[0].Name); var name =this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters[0].Name);
var parameter = (argExp as LambdaExpression).Parameters.Last(); var parameter = (argExp as LambdaExpression).Parameters.Last();
Context.InitMappingInfo(parameter.Type); foreach (var item in (argExp as LambdaExpression).Parameters)
{
Context.InitMappingInfo(item.Type);
}
this.Context.RefreshMapping(); this.Context.RefreshMapping();
var tableName= Context.GetTranslationTableName(parameter.Type.Name, true); var tableName= Context.GetTranslationTableName(parameter.Type.Name, true);
var joinString =string.Format(" {2} LEFT JOIN {1} {0} ", var joinString =string.Format(" {2} LEFT JOIN {1} {0} ",

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

@ -45,7 +45,13 @@ namespace SqlSugar
new SubSelect() { Context = this.Context }.SetShortName(exp, "+"); new SubSelect() { Context = this.Context }.SetShortName(exp, "+");
} }
var argExp = exp.Arguments[0]; var argExp = exp.Arguments[0];
var result = "WHERE " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple); var copyContext = this.Context;
if (this.Context.JoinIndex > 0)
{
copyContext = this.Context.GetCopyContextWithMapping();
copyContext.IsSingle = false;
}
var result = "WHERE " + SubTools.GetMethodValue(copyContext, argExp, ResolveExpressType.WhereMultiple);

Loading…
Cancel
Save