Browse Source

-

pull/12/MERGE
skx 4 years ago
parent
commit
91d02f18b7
  1. 13
      Src/Asp.Net/SqlSugar/ExpressionsToSql/CaseWhen/CaseWhenResolve.cs

13
Src/Asp.Net/SqlSugar/ExpressionsToSql/CaseWhen/CaseWhenResolve.cs

@ -16,10 +16,13 @@ namespace SqlSugar
this.context = context;
var currentExpression = expression;
allMethods.Add(currentExpression);
if (context.IsSingle && oppsiteExpression != null&& oppsiteExpression is MemberExpression)
if (context.IsSingle && oppsiteExpression != null && oppsiteExpression is MemberExpression)
{
var childExpression = (oppsiteExpression as MemberExpression).Expression;
this.context.SingleTableNameSubqueryShortName = (childExpression as ParameterExpression).Name;
if ((childExpression as ParameterExpression) != null)
{
this.context.SingleTableNameSubqueryShortName = (childExpression as ParameterExpression).Name;
}
}
else if (context.IsSingle)
{
@ -41,11 +44,11 @@ namespace SqlSugar
foreach (var methodExp in allMethods)
{
var isFirst = allMethods.First() == methodExp;
var isLast= allMethods.Last() == methodExp;
var sql= SubTools.GetMethodValue(this.context, methodExp.Arguments[0],this.context.IsSingle?ResolveExpressType.WhereSingle:ResolveExpressType.WhereMultiple);
var isLast = allMethods.Last() == methodExp;
var sql = SubTools.GetMethodValue(this.context, methodExp.Arguments[0], this.context.IsSingle ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple);
sqls.Add(new KeyValuePair<string, string>(methodExp.Method.Name, sql));
}
var result= this.context.DbMehtods.CaseWhen(sqls);
var result = this.context.DbMehtods.CaseWhen(sqls);
return result;
}
}

Loading…
Cancel
Save