mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-01-26 21:38:32 +08:00
Subquery join bug
This commit is contained in:
@@ -50,7 +50,7 @@ namespace SqlSugar
|
||||
var joinString =string.Format(" {2} INNER JOIN {1} {0} ",
|
||||
this.Context.GetTranslationColumnName(parameter.Name),
|
||||
tableName,
|
||||
this.Context.JoinIndex==0?name:"");
|
||||
this.Context.JoinIndex==1?name:"");
|
||||
var result = joinString+ "ON " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
|
||||
//var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||
this.Context.JoinIndex++;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace SqlSugar
|
||||
var joinString =string.Format(" {2} LEFT JOIN {1} {0} ",
|
||||
this.Context.GetTranslationColumnName(parameter.Name),
|
||||
tableName,
|
||||
this.Context.JoinIndex==0?name:"");
|
||||
this.Context.JoinIndex==1?name:"");
|
||||
var result = joinString+ "ON " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);
|
||||
//var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||
this.Context.JoinIndex++;
|
||||
|
||||
@@ -49,7 +49,10 @@ namespace SqlSugar
|
||||
this.Context.InitMappingInfo(entityType);
|
||||
this.Context.RefreshMapping();
|
||||
}
|
||||
if(this.Context.JoinIndex==0)
|
||||
return SubTools.GetMethodValue(this.Context, exp.Arguments[0],ResolveExpressType.FieldSingle);
|
||||
else
|
||||
return SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldMultiple);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,11 +135,17 @@ namespace SqlSugar
|
||||
}
|
||||
isubList = isubList.OrderBy(it => it.Sort).ToList();
|
||||
var isHasWhere = isubList.Where(it => it is SubWhere).Any();
|
||||
var isJoin = isubList.Any(it => it is SubInnerJoin || it is SubLeftJoin);
|
||||
if (isJoin)
|
||||
{
|
||||
this.context.JoinIndex++;
|
||||
}
|
||||
List<string> result = isubList.Select(it =>
|
||||
{
|
||||
it.HasWhere = isHasWhere;
|
||||
return it.GetValue(it.Expression);
|
||||
}).ToList();
|
||||
this.context.JoinIndex = 0;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user