mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
Analytic optimization
This commit is contained in:
parent
f329f299b1
commit
9675f05e81
@ -112,6 +112,10 @@ namespace OrmTest.UnitTest
|
||||
|
||||
var t11= db.Queryable<Student>().GroupBy("id").OrderBy("id").Select("id").ToSql();
|
||||
base.Check("SELECT id FROM [STudent] GROUP BY id ORDER BY id ", null, t11.Key, t11.Value, "single t11 error");
|
||||
|
||||
|
||||
var t12 = db.Queryable<Student>().Where(it=>it.Id!=null).ToSql();
|
||||
base.Check("SELECT [ID],[SchoolId],[Name],[CreateTime] FROM [STudent] WHERE ( [ID] IS NOT NULL )", null, t12.Key, t12.Value, "single t12 error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,6 +170,33 @@ namespace SqlSugar
|
||||
this.Context.Result.Append(appendValue);
|
||||
}
|
||||
}
|
||||
else if ((oppoSiteExpression is UnaryExpression && (oppoSiteExpression as UnaryExpression).Operand is MemberExpression)) {
|
||||
string appendValue = Context.SqlParameterKeyWord
|
||||
+ ((MemberExpression)(oppoSiteExpression as UnaryExpression).Operand).Member.Name
|
||||
+ Context.ParameterIndex;
|
||||
if (value.ObjToString() != "NULL" && !parameter.ValueIsNull)
|
||||
{
|
||||
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
|
||||
}
|
||||
else
|
||||
{
|
||||
appendValue = value.ObjToString();
|
||||
}
|
||||
Context.ParameterIndex++;
|
||||
appendValue = string.Format(" {0} ", appendValue);
|
||||
if (isLeft == true)
|
||||
{
|
||||
appendValue += ExpressionConst.Format1 + parameter.BaseParameter.Index;
|
||||
}
|
||||
if (this.Context.Result.Contains(ExpressionConst.Format0))
|
||||
{
|
||||
this.Context.Result.Replace(ExpressionConst.Format0, appendValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Context.Result.Append(appendValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var appendValue = this.Context.SqlParameterKeyWord + ExpressionConst.Const + Context.ParameterIndex;
|
||||
|
@ -44,6 +44,7 @@ namespace SqlSugar
|
||||
if (lsbs && parameter.ValueIsNull)
|
||||
{
|
||||
base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, isEqual ? "IS" : "IS NOT");
|
||||
base.Context.Result.Replace(ExpressionConst.Format1 + (parameter.Index+1), isEqual ? "IS" : "IS NOT");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -24,7 +24,13 @@ namespace SqlSugar
|
||||
base.Expression = expression.Operand;
|
||||
var isMember = expression.Operand is MemberExpression;
|
||||
var isConst = expression.Operand is ConstantExpression;
|
||||
if (baseParameter.CurrentExpression is NewArrayExpression)
|
||||
var offsetIsNull = (parameter.OppsiteExpression is ConstantExpression)
|
||||
&&(parameter.OppsiteExpression as ConstantExpression).Value==null
|
||||
&&ExpressionTool.IsComparisonOperator(expression.Operand);
|
||||
if (isMember && offsetIsNull) {
|
||||
Append(parameter, nodeType);
|
||||
}
|
||||
else if (baseParameter.CurrentExpression is NewArrayExpression)
|
||||
{
|
||||
Result(parameter, nodeType);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user