Update exp to sql

This commit is contained in:
sunkaixuna 2022-01-04 13:06:59 +08:00
parent bd381f7953
commit c2ef56a223
2 changed files with 17 additions and 0 deletions

View File

@ -72,5 +72,17 @@ namespace SqlSugar
}
}
public void SetShortNameNext(MethodCallExpression exp, string result)
{
if (exp.Arguments.Count>1&&exp.Arguments[1] is LambdaExpression && result.IsContainsIn("+", "-"))
{
var parameters = (exp.Arguments[1] as LambdaExpression).Parameters;
if (parameters != null && parameters.Count > 0)
{
this.Context.CurrentShortName = this.Context.SqlTranslationLeft + parameters[0] + this.Context.SqlTranslationRight;
}
}
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
namespace SqlSugar
{
@ -48,6 +49,10 @@ namespace SqlSugar
{
Check.Exception(true, ErrorMessage.WhereIFCheck,exp.Arguments[0].ToString());
}
if (Regex.Matches(expression.ToString(), "Subqueryable").Count >= 2)
{
new SubSelect() { Context = this.Context }.SetShortNameNext(exp, "+");
}
var isWhere= Convert.ToBoolean(value);
if (!Convert.ToBoolean(isWhere)) {
return "WHERE 1=1 ";