EXP Analytic optimization

This commit is contained in:
sunkaixuan 2017-07-11 13:27:41 +08:00
parent d3de52b89f
commit 8324841fab
4 changed files with 31 additions and 4 deletions

View File

@ -16,10 +16,25 @@ namespace SqlSugar
{
#region Fields
private bool _IsSingle = true;
private IDbMethods _DbMehtods { get; set; }
#endregion
#region properties
public IDbMethods DbMehtods { get; set; }
public IDbMethods DbMehtods
{
get
{
if (_DbMehtods == null)
{
_DbMehtods = new DefaultDbMethod();
}
return _DbMehtods;
}
set
{
_DbMehtods = value;
}
}
public int Index { get; set; }
public int ParameterIndex { get; set; }
public MappingColumnList MappingColumns { get; set; }

View File

@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public abstract partial class DefaultDbMethod : IDbMethods
public partial class DefaultDbMethod : IDbMethods
{
public virtual string IIF(MethodCallExpressionModel model)
{
@ -260,5 +260,15 @@ namespace SqlSugar
var parameter1 = model.Args[1];
return string.Format("{0}", parameter1.MemberValue);
}
public virtual string True()
{
return "( 1 = 1 ) ";
}
public virtual string False()
{
return "( 1 = 2 ) ";
}
}
}

View File

@ -47,5 +47,7 @@ namespace SqlSugar
string AggregateMax(MethodCallExpressionModel model);
string AggregateCount(MethodCallExpressionModel model);
string MappingColumn(MethodCallExpressionModel model);
string True();
string False();
}
}

View File

@ -35,7 +35,7 @@ namespace SqlSugar
var parentIsRoot = parameter.BaseParameter.CurrentExpression is LambdaExpression;
if (parentIsRoot && value != null && value.GetType() == PubConst.BoolType)
{
this.Context.Result.Append(value.ObjToBool() ? "( 1 = 1 ) " : "( 1 = 2 ) ");
this.Context.Result.Append(value.ObjToBool() ? this.Context.DbMehtods.True() :this.Context.DbMehtods.False());
break;
}
if (parentIsBinary && value != null && value.GetType() == PubConst.BoolType && parameter.BaseExpression != null)
@ -47,7 +47,7 @@ namespace SqlSugar
parameter.BaseExpression.NodeType == ExpressionType.OrElse;
if (isLogicOperator)
{
AppendMember(parameter, isLeft, (value.ObjToBool() ? "( 1 = 1 ) " : "( 1 = 2 ) "));
AppendMember(parameter, isLeft, (value.ObjToBool() ? this.Context.DbMehtods.True(): this.Context.DbMehtods.False()));
break;
}
}