public MemberNewExpressionResolve(ExpressionParameter parameter) : base(parameter)
        {
            var    expression = base.Expression as MemberExpression;
            var    isLeft     = parameter.IsLeft;
            object value      = null;

            value = ExpressionTool.DynamicInvoke(expression);
        }
Exemple #2
0
        private void MemberLogic(ExpressionParameter parameter, ExpressionParameter baseParameter, ExpressionType nodeType)
        {
            var memberExpression = (base.Expression as MemberExpression);
            var isLogicOperator  = ExpressionTool.IsLogicOperator(baseParameter.OperatorValue) || baseParameter.OperatorValue.IsNullOrEmpty();
            var isHasValue       = isLogicOperator && memberExpression.Member.Name == "HasValue" && memberExpression.Expression != null && memberExpression.NodeType == ExpressionType.MemberAccess;

            if (isHasValue)
            {
                var member = memberExpression.Expression as MemberExpression;
                parameter.CommonTempData = CommonTempDataType.Result;
                var isConst = member.Expression != null && member.Expression is ConstantExpression;
                if (isConst)
                {
                    var paramterValue = ExpressionTool.DynamicInvoke(member);
                    var paramterName  = base.AppendParameter(paramterValue);
                    var result        = this.Context.DbMehtods.HasValue(new MethodCallExpressionModel()
                    {
                        Args = new List <MethodCallExpressionArgs>()
                        {
                            new MethodCallExpressionArgs()
                            {
                                IsMember = false, MemberName = paramterName, MemberValue = paramterValue
                            }
                        }
                    });
                    this.Context.Result.Append(result);
                }
                else
                {
                    this.Expression = isConst ? member.Expression : member;
                    this.Start();
                    var methodParamter = isConst ? new MethodCallExpressionArgs()
                    {
                        IsMember = false
                    } : new MethodCallExpressionArgs()
                    {
                        IsMember = true, MemberName = parameter.CommonTempData, MemberValue = null
                    };
                    var result = this.Context.DbMehtods.HasValue(new MethodCallExpressionModel()
                    {
                        Args = new List <MethodCallExpressionArgs>()
                        {
                            methodParamter
                        }
                    });
                    this.Context.Result.Append(result);
                    parameter.CommonTempData = null;
                }
            }
            else if (memberExpression.Type == UtilConstants.BoolType && isLogicOperator)
            {
                Append(parameter, nodeType);
            }
            else
            {
                Result(parameter, nodeType);
            }
        }
Exemple #3
0
        protected void Where(ExpressionParameter parameter, bool?isLeft, string name, IEnumerable <Expression> args, MethodCallExpressionModel model, List <MethodCallExpressionArgs> appendArgs = null)
        {
            foreach (var item in args)
            {
                var expItem = item;
                if (item is UnaryExpression)
                {
                    expItem = (item as UnaryExpression).Operand;
                }
                AppendItem(parameter, name, args, model, expItem);
            }
            if (appendArgs != null)
            {
                model.Args.AddRange(appendArgs);
            }
            var methodValue = GetMethodValue(name, model);

            if (parameter.BaseExpression is BinaryExpression && parameter.OppsiteExpression.Type == UtilConstants.BoolType && name == "HasValue" && !(parameter.OppsiteExpression is BinaryExpression) && !(parameter.OppsiteExpression is MethodCallExpression && parameter.OppsiteExpression.Type == UtilConstants.BoolType))
            {
                methodValue = packIfElse(methodValue);
            }
            if (parameter.OppsiteExpression != null && name == "IsNullOrEmpty" && parameter.OppsiteExpression.Type == UtilConstants.BoolType && parameter.OppsiteExpression is ConstantExpression)
            {
                methodValue = packIfElse(methodValue);
            }
            var isRoot = contextIndex == 2;

            if (isRoot && parameter.BaseExpression == null && this.Context.ResolveType.IsIn(ResolveExpressType.WhereMultiple, ResolveExpressType.WhereSingle) && (parameter.CurrentExpression is MethodCallExpression) && ((parameter.CurrentExpression as MethodCallExpression).Method.Name.IsIn("ToBool", "ToBoolean")))
            {
                methodValue = methodValue + "=1 ";
                ;
            }
            if (isRoot && parameter.BaseExpression == null && this.Context.ResolveType.IsIn(ResolveExpressType.WhereMultiple, ResolveExpressType.WhereSingle) && (parameter.CurrentExpression is ConditionalExpression) && ((parameter.CurrentExpression as ConditionalExpression).Type == UtilConstants.BoolType))
            {
                methodValue = methodValue + "=1 ";
            }
            if (isRoot && parameter.BaseExpression == null && this.Context.ResolveType.IsIn(ResolveExpressType.WhereMultiple, ResolveExpressType.WhereSingle) && (parameter.CurrentExpression is MethodCallExpression) && ((parameter.CurrentExpression as MethodCallExpression).Method.Name.IsIn("IIF")) && (parameter.CurrentExpression as MethodCallExpression).Method.ReturnType == UtilConstants.BoolType)
            {
                methodValue = methodValue + "=1 ";
            }
            if (parameter.BaseExpression != null && ExpressionTool.IsLogicOperator(parameter.BaseExpression) && this.Context.ResolveType.IsIn(ResolveExpressType.WhereMultiple, ResolveExpressType.WhereSingle) && (parameter.CurrentExpression is ConditionalExpression) && ((parameter.CurrentExpression as ConditionalExpression).Type == UtilConstants.BoolType))
            {
                methodValue = methodValue + "=1 ";
            }
            if (parameter.BaseExpression != null && ExpressionTool.IsLogicOperator(parameter.BaseExpression) && this.Context.ResolveType.IsIn(ResolveExpressType.WhereMultiple, ResolveExpressType.WhereSingle) && (parameter.CurrentExpression is MethodCallExpression) && ((parameter.CurrentExpression as MethodCallExpression).Method.Name.IsIn("IIF")) && (parameter.CurrentExpression as MethodCallExpression).Method.ReturnType == UtilConstants.BoolType)
            {
                methodValue = methodValue + "=1 ";
            }
            if (parameter.BaseExpression != null && ExpressionTool.IsLogicOperator(parameter.BaseExpression) && this.Context.ResolveType.IsIn(ResolveExpressType.WhereMultiple, ResolveExpressType.WhereSingle) && (parameter.CurrentExpression is MethodCallExpression) && ((parameter.CurrentExpression as MethodCallExpression).Method.Name.IsIn("ToBool", "ToBoolean")))
            {
                methodValue = methodValue + "=1 ";
            }
            base.AppendValue(parameter, isLeft, methodValue);
        }
Exemple #4
0
        private void ResolveMemberValue(ExpressionParameter parameter, ExpressionParameter baseParameter, bool?isLeft, bool isSetTempData, MemberExpression expression)
        {
            var value = ExpressionTool.GetMemberValue(expression.Member, expression);

            if (isSetTempData)
            {
                baseParameter.CommonTempData = value;
            }
            else
            {
                AppendValue(parameter, isLeft, value);
            }
        }
Exemple #5
0
        private void AppendItem(ExpressionParameter parameter, string name, IEnumerable <Expression> args, MethodCallExpressionModel model, Expression item)
        {
            if (ExpressionTool.IsUnConvertExpress(item))
            {
                item = (item as UnaryExpression).Operand;
            }
            var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
            var isConst            = item is ConstantExpression;
            var isIIF           = name == "IIF";
            var isIFFBoolMember = isIIF && (item is MemberExpression) && (item as MemberExpression).Type == UtilConstants.BoolType;
            var isIFFUnary      = isIIF && (item is UnaryExpression) && (item as UnaryExpression).Operand.Type == UtilConstants.BoolType;
            var isIFFBoolBinary = isIIF && (item is BinaryExpression) && (item as BinaryExpression).Type == UtilConstants.BoolType;
            var isIFFBoolMethod = isIIF && (item is MethodCallExpression) && (item as MethodCallExpression).Type == UtilConstants.BoolType;
            var isFirst         = item == args.First();

            if (isFirst && isIIF && isConst)
            {
                var value = (item as ConstantExpression).Value.ObjToBool() ? this.Context.DbMehtods.True() : this.Context.DbMehtods.False();
                var methodCallExpressionArgs = new MethodCallExpressionArgs()
                {
                    IsMember    = true,
                    MemberName  = value,
                    MemberValue = value
                };
                model.Args.Add(methodCallExpressionArgs);
            }
            else if (isIFFUnary && !isFirst)
            {
                AppendModelByIIFMember(parameter, model, (item as UnaryExpression).Operand);
            }
            else if (isIFFBoolMember && !isFirst)
            {
                AppendModelByIIFMember(parameter, model, item);
            }
            else if (isIFFBoolBinary && !isFirst)
            {
                AppendModelByIIFBinary(parameter, model, item);
            }
            else if (isIFFBoolMethod && !isFirst)
            {
                AppendModelByIIFMethod(parameter, model, item);
            }
            else if (isBinaryExpression)
            {
                model.Args.Add(GetMethodCallArgs(parameter, item));
            }
            else
            {
                AppendModel(parameter, model, item);
            }
        }
        public IUpdateable <T> SetColumns(Expression <Func <T, bool> > columns)
        {
            CheckTranscodeing();
            var binaryExp = columns.Body as BinaryExpression;

            Check.Exception(!binaryExp.NodeType.IsIn(ExpressionType.Equal), "No support {0}", columns.ToString());
            Check.Exception(!(binaryExp.Left is MemberExpression) && !(binaryExp.Left is UnaryExpression), "No support {0}", columns.ToString());
            Check.Exception(ExpressionTool.IsConstExpression(binaryExp.Left as MemberExpression), "No support {0}", columns.ToString());
            var    expResult = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.WhereSingle).GetResultString().Replace(")", " )").Replace("(", "( ").Trim().TrimStart('(').TrimEnd(')');
            string key       = SqlBuilder.GetNoTranslationColumnName(expResult);

            UpdateBuilder.SetValues.Add(new KeyValuePair <string, string>(SqlBuilder.GetTranslationColumnName(key), expResult));
            this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => (UpdateParameterIsNull == false && IsPrimaryKey(it)) || UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase) || SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList();
            AppendSets();
            return(this);
        }
Exemple #7
0
        public MemberNoExpressionResolve(ExpressionParameter parameter) : base(parameter)
        {
            var    expression    = base.Expression as MemberExpression;
            var    isLeft        = parameter.IsLeft;
            object value         = null;
            var    isField       = expression.Member is System.Reflection.FieldInfo;
            var    isProperty    = expression.Member is System.Reflection.PropertyInfo;
            var    baseParameter = parameter.BaseParameter;
            var    isSetTempData = baseParameter.CommonTempData.HasValue() && baseParameter.CommonTempData.Equals(CommonTempDataType.Result);

            if (isField)
            {
                value = ExpressionTool.GetFiledValue(expression);
            }
            else if (isProperty)
            {
                value = ExpressionTool.GetPropertyValue(expression);
            }
            switch (base.Context.ResolveType)
            {
            case ResolveExpressType.WhereSingle:
            case ResolveExpressType.WhereMultiple:
            case ResolveExpressType.SelectSingle:
            case ResolveExpressType.SelectMultiple:
            case ResolveExpressType.Update:
                if (isSetTempData)
                {
                    baseParameter.CommonTempData = value;
                }
                else
                {
                    AppendValue(parameter, isLeft, value);
                }
                break;

            case ResolveExpressType.FieldSingle:
                break;

            case ResolveExpressType.FieldMultiple:
                break;

            default:
                break;
            }
        }
Exemple #8
0
 private void NewValueType(ExpressionParameter parameter, NewExpression expression)
 {
     try
     {
         var value         = ExpressionTool.DynamicInvoke(expression);
         var isSetTempData = parameter.CommonTempData.HasValue() && parameter.CommonTempData.Equals(CommonTempDataType.Result);
         if (isSetTempData)
         {
             parameter.CommonTempData = value;
         }
         else
         {
             AppendValue(parameter, parameter.IsLeft, value);
         }
     }
     catch (Exception ex)
     {
         Check.Exception(expression.Type == UtilConstants.DateType, "ThrowNotSupportedException {0} ", ex.ToString());
     }
 }
Exemple #9
0
 private void CusMethod(ExpressionParameter parameter, MethodCallExpression express, bool?isLeft)
 {
     try
     {
         var constValue = ExpressionTool.DynamicInvoke(express);
         parameter.BaseParameter.CommonTempData = constValue;
         var parameterName = base.AppendParameter(constValue);
         if (parameter.BaseParameter.CommonTempData != null && parameter.BaseParameter.CommonTempData.Equals(CommonTempDataType.Result))
         {
             this.Context.Result.Append(parameterName);
         }
         else
         {
             base.AppendValue(parameter, isLeft, parameterName);
         }
     }
     catch
     {
         Check.Exception(true, string.Format(ErrorMessage.MethodError, express.Method.Name));
     }
 }
Exemple #10
0
 private void ResolveCallValue(ExpressionParameter parameter, ExpressionParameter baseParameter, MemberExpression expression, bool?isLeft, bool isSetTempData, bool isSingle)
 {
     try
     {
         baseParameter.ChildExpression = expression;
         string fieldName = string.Empty;
         if (isSetTempData)
         {
             var value = ExpressionTool.DynamicInvoke(expression);
             baseParameter.CommonTempData = value;
         }
         else
         {
             var value = ExpressionTool.DynamicInvoke(expression);
             base.AppendValue(parameter, isLeft, value);
         }
     }
     catch
     {
         Check.Exception(true, "Not Support {0}", expression.ToString());
     }
 }
        public MemberConstExpressionResolve(ExpressionParameter parameter) : base(parameter)
        {
            var    expression    = base.Expression as MemberExpression;
            var    isLeft        = parameter.IsLeft;
            object value         = ExpressionTool.GetMemberValue(expression.Member, expression);
            var    baseParameter = parameter.BaseParameter;
            var    isSetTempData = baseParameter.CommonTempData.HasValue() && baseParameter.CommonTempData.Equals(CommonTempDataType.Result);

            switch (parameter.Context.ResolveType)
            {
            case ResolveExpressType.Update:
            case ResolveExpressType.SelectSingle:
            case ResolveExpressType.SelectMultiple:
                if (value != null && value.GetType().IsEnum())
                {
                    value = Convert.ToInt64(value);
                }
                parameter.BaseParameter.CommonTempData = value;
                break;

            case ResolveExpressType.WhereSingle:
            case ResolveExpressType.WhereMultiple:
                if (isSetTempData)
                {
                    baseParameter.CommonTempData = value;
                }
                else
                {
                    AppendValue(parameter, isLeft, value);
                }
                break;

            case ResolveExpressType.FieldSingle:
            case ResolveExpressType.FieldMultiple:
                break;
            }
        }
Exemple #12
0
        private void ResolveHasValue(ExpressionParameter parameter, MemberExpression expression)
        {
            parameter.CommonTempData = CommonTempDataType.Result;
            this.Expression          = expression.Expression;
            this.Start();
            var methodParamter = new MethodCallExpressionArgs()
            {
                IsMember = true, MemberName = parameter.CommonTempData, MemberValue = null
            };

            if (expression.Expression?.Type != null)
            {
                methodParamter.Type = UtilMethods.GetUnderType(expression.Expression?.Type);
            }
            var result = this.Context.DbMehtods.HasValue(new MethodCallExpressionModel()
            {
                Args = new List <MethodCallExpressionArgs>()
                {
                    methodParamter
                }
            });

            if (parameter.BaseExpression != null && ExpressionTool.IsLogicOperator(parameter.BaseExpression) && parameter.IsLeft == true)
            {
                if (base.Context.Result.Contains(ExpressionConst.FormatSymbol))
                {
                    base.Context.Result.Replace(ExpressionConst.FormatSymbol, "");
                }
                this.Context.Result.Append(result + " " + ExpressionTool.GetOperator(parameter.BaseExpression.NodeType) + " ");
            }
            else
            {
                this.Context.Result.Append(result);
            }
            parameter.CommonTempData = null;
        }
Exemple #13
0
        private void ResolveDateValue(ExpressionParameter parameter, bool?isLeft, MemberExpression expression)
        {
            var name = expression.Member.Name;
            var oldCommonTempDate = parameter.CommonTempData;

            parameter.CommonTempData = CommonTempDataType.Result;
            this.Expression          = expression.Expression;
            var isConst = this.Expression is ConstantExpression;

            if (this.Expression.Type == UtilConstants.DateType && this.Expression.ToString() == "DateTime.Now")
            {
                this.Expression = expression;
                var parameterName = base.AppendParameter(ExpressionTool.GetMemberValue(expression.Member, expression));
                base.AppendMember(parameter, isLeft, parameterName);
            }
            else
            {
                this.Start();
                var result = this.Context.DbMehtods.DateValue(new MethodCallExpressionModel()
                {
                    Args = new List <MethodCallExpressionArgs>()
                    {
                        new MethodCallExpressionArgs()
                        {
                            IsMember = !isConst, MemberName = parameter.CommonTempData, MemberValue = null
                        },
                        new MethodCallExpressionArgs()
                        {
                            IsMember = true, MemberName = name, MemberValue = name
                        }
                    }
                });
                base.AppendMember(parameter, isLeft, result);
            }
            parameter.CommonTempData = oldCommonTempDate;
        }
Exemple #14
0
 protected void ResolveNewExpressions(ExpressionParameter parameter, Expression item, string asName)
 {
     if (item is ConstantExpression)
     {
         this.Expression = item;
         this.Start();
         string parameterName = this.Context.SqlParameterKeyWord + "constant" + this.Context.ParameterIndex;
         this.Context.ParameterIndex++;
         parameter.Context.Result.Append(this.Context.GetAsString(asName, parameterName));
         this.Context.Parameters.Add(new DbLiteParameter(parameterName, parameter.CommonTempData));
     }
     else if ((item is MemberExpression) && ((MemberExpression)item).Expression == null)
     {
         var    paramterValue = ExpressionTool.GetPropertyValue(item as MemberExpression);
         string parameterName = this.Context.SqlParameterKeyWord + "constant" + this.Context.ParameterIndex;
         this.Context.ParameterIndex++;
         parameter.Context.Result.Append(this.Context.GetAsString(asName, parameterName));
         this.Context.Parameters.Add(new DbLiteParameter(parameterName, paramterValue));
     }
     else if ((item is MemberExpression) && ((MemberExpression)item).Expression.NodeType == ExpressionType.Constant)
     {
         this.Expression = item;
         this.Start();
         string parameterName = this.Context.SqlParameterKeyWord + "constant" + this.Context.ParameterIndex;
         this.Context.ParameterIndex++;
         parameter.Context.Result.Append(this.Context.GetAsString(asName, parameterName));
         this.Context.Parameters.Add(new DbLiteParameter(parameterName, parameter.CommonTempData));
     }
     else if (item is MemberExpression)
     {
         if (this.Context.Result.IsLockCurrentParameter == false)
         {
             this.Context.Result.CurrentParameter       = parameter;
             this.Context.Result.IsLockCurrentParameter = true;
             parameter.IsAppendTempDate();
             this.Expression = item;
             this.Start();
             parameter.IsAppendResult();
             this.Context.Result.Append(this.Context.GetAsString(asName, parameter.CommonTempData.ObjToString()));
             this.Context.Result.CurrentParameter = null;
         }
     }
     else if (item is UnaryExpression && ((UnaryExpression)item).Operand is MemberExpression)
     {
         if (this.Context.Result.IsLockCurrentParameter == false)
         {
             var expression    = ((UnaryExpression)item).Operand as MemberExpression;
             var isDateTimeNow = ((UnaryExpression)item).Operand.ToString() == "DateTime.Now";
             if (expression.Expression == null && !isDateTimeNow)
             {
                 this.Context.Result.CurrentParameter       = parameter;
                 this.Context.Result.IsLockCurrentParameter = true;
                 parameter.IsAppendTempDate();
                 this.Expression = item;
                 this.Start();
                 parameter.IsAppendResult();
                 this.Context.Result.Append(this.Context.GetAsString(asName, parameter.CommonTempData.ObjToString()));
                 this.Context.Result.CurrentParameter = null;
             }
             else if (expression.Expression is ConstantExpression || isDateTimeNow)
             {
                 string parameterName = this.Context.SqlParameterKeyWord + "constant" + this.Context.ParameterIndex;
                 this.Context.ParameterIndex++;
                 parameter.Context.Result.Append(this.Context.GetAsString(asName, parameterName));
                 this.Context.Parameters.Add(new DbLiteParameter(parameterName, ExpressionTool.GetMemberValue(expression.Member, expression)));
             }
             else
             {
                 this.Context.Result.CurrentParameter       = parameter;
                 this.Context.Result.IsLockCurrentParameter = true;
                 parameter.IsAppendTempDate();
                 this.Expression = item;
                 this.Start();
                 parameter.IsAppendResult();
                 this.Context.Result.Append(this.Context.GetAsString(asName, parameter.CommonTempData.ObjToString()));
                 this.Context.Result.CurrentParameter = null;
             }
         }
     }
     else if (item is UnaryExpression && ((UnaryExpression)item).Operand is ConstantExpression)
     {
         if (this.Context.Result.IsLockCurrentParameter == false)
         {
             this.Expression = ((UnaryExpression)item).Operand;
             this.Start();
             string parameterName = this.Context.SqlParameterKeyWord + "constant" + this.Context.ParameterIndex;
             this.Context.ParameterIndex++;
             parameter.Context.Result.Append(this.Context.GetAsString(asName, parameterName));
             this.Context.Parameters.Add(new DbLiteParameter(parameterName, parameter.CommonTempData));
         }
     }
     else if (item is BinaryExpression)
     {
         if (this.Context.Result.IsLockCurrentParameter == false)
         {
             var newContext         = this.Context.GetCopyContextWithMapping();
             var resolveExpressType = this.Context.IsSingle ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple;
             newContext.Resolve(item, resolveExpressType);
             this.Context.Index          = newContext.Index;
             this.Context.ParameterIndex = newContext.ParameterIndex;
             if (newContext.Parameters.HasValue())
             {
                 this.Context.Parameters.AddRange(newContext.Parameters);
             }
             this.Context.Result.Append(this.Context.GetAsString(asName, newContext.Result.GetString()));
             this.Context.Result.CurrentParameter = null;
             if (this.Context.SingleTableNameSubqueryShortName.IsNullOrEmpty() && newContext.SingleTableNameSubqueryShortName.HasValue())
             {
                 this.Context.SingleTableNameSubqueryShortName = newContext.SingleTableNameSubqueryShortName;
             }
         }
     }
     else if (item.Type.IsClass())
     {
         this.Expression = item;
         this.Start();
         var shortName      = parameter.CommonTempData;
         var listProperties = item.Type.GetProperties().Cast <PropertyInfo>().ToList();
         foreach (var property in listProperties)
         {
             var hasIgnore = this.Context.IgnoreComumnList != null && this.Context.IgnoreComumnList.Any(it => it.EntityName.Equals(item.Type.Name, StringComparison.CurrentCultureIgnoreCase) && it.PropertyName.Equals(property.Name, StringComparison.CurrentCultureIgnoreCase));
             if (hasIgnore)
             {
                 continue;
             }
             if (property.PropertyType.IsClass())
             {
             }
             else
             {
                 var propertyName = property.Name;
                 var dbColumnName = propertyName;
                 var mappingInfo  = this.Context.MappingColumns.FirstOrDefault(it => it.EntityName == item.Type.Name && it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
                 if (mappingInfo.HasValue())
                 {
                     dbColumnName = mappingInfo.DbColumnName;
                 }
                 asName = this.Context.GetTranslationText(item.Type.Name + "." + propertyName);
                 if (Context.IsJoin)
                 {
                     this.Context.Result.Append(Context.GetAsString(asName, dbColumnName, shortName.ObjToString()));
                 }
                 else
                 {
                     this.Context.Result.Append(Context.GetAsString(asName, dbColumnName));
                 }
             }
         }
     }
     else if (item.Type == UtilConstants.BoolType && item is MethodCallExpression && (item as MethodCallExpression).Method.Name == "Any" && IsSubMethod(item as MethodCallExpression))
     {
         this.Expression = item;
         this.Start();
         var sql = this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
         {
             Args = new List <MethodCallExpressionArgs>()
             {
                 new MethodCallExpressionArgs()
                 {
                     IsMember   = true,
                     MemberName = parameter.CommonTempData.ObjToString()
                 },
                 new MethodCallExpressionArgs()
                 {
                     IsMember   = true,
                     MemberName = 1
                 },
                 new MethodCallExpressionArgs()
                 {
                     IsMember   = true,
                     MemberName = 0
                 }
             }
         });
         parameter.Context.Result.Append(this.Context.GetAsString(asName, sql));
     }
     else if (item is MethodCallExpression || item is UnaryExpression || item is ConditionalExpression || item.NodeType == ExpressionType.Coalesce)
     {
         this.Expression = item;
         this.Start();
         parameter.Context.Result.Append(this.Context.GetAsString(asName, parameter.CommonTempData.ObjToString()));
     }
     else
     {
         Check.ThrowNotSupportedException(item.GetType().Name);
     }
 }
Exemple #15
0
        public BinaryExpressionResolve(ExpressionParameter parameter) : base(parameter)
        {
            var expression           = this.Expression as BinaryExpression;
            var operatorValue        = parameter.OperatorValue = ExpressionTool.GetOperator(expression.NodeType);
            var isEqual              = expression.NodeType == ExpressionType.Equal;
            var isComparisonOperator = ExpressionTool.IsComparisonOperator(expression);

            base.ExactExpression = expression;
            var leftExpression  = expression.Left;
            var rightExpression = expression.Right;
            var leftIsBinary    = leftExpression is BinaryExpression;
            var rightBinary     = rightExpression is BinaryExpression;
            var lbrs            = leftIsBinary && !rightBinary;
            var lsrb            = !leftIsBinary && rightBinary;
            var lbrb            = rightBinary && leftIsBinary;
            var lsbs            = !leftIsBinary && !rightBinary;
            var isAppend        = !base.Context.Result.Contains(ExpressionConst.FormatSymbol);

            if (isAppend)
            {
                base.Context.Result.Append(ExpressionConst.LeftParenthesis);
                base.Context.Result.Append(ExpressionConst.FormatSymbol);
            }
            else
            {
                base.Context.Result.Replace(ExpressionConst.FormatSymbol, ExpressionConst.LeftParenthesis + ExpressionConst.FormatSymbol);
            }
            if (leftExpression is UnaryExpression && (leftExpression as UnaryExpression).Operand is UnaryExpression && (leftExpression as UnaryExpression).NodeType == ExpressionType.Convert)
            {
                leftExpression = (leftExpression as UnaryExpression).Operand;
            }
            if (leftExpression is UnaryExpression && (leftExpression as UnaryExpression).Operand.Type == UtilConstants.BoolType && (leftExpression as UnaryExpression).NodeType == ExpressionType.Convert && rightExpression.Type == UtilConstants.BoolTypeNull)
            {
                leftExpression = (leftExpression as UnaryExpression).Operand;
            }
            if (rightExpression is UnaryExpression && (rightExpression as UnaryExpression).Operand.Type == UtilConstants.BoolType && (rightExpression as UnaryExpression).NodeType == ExpressionType.Convert)
            {
                rightExpression = (rightExpression as UnaryExpression).Operand;
            }
            parameter.LeftExpression  = leftExpression;
            parameter.RightExpression = rightExpression;
            base.Expression           = leftExpression;
            base.IsLeft = true;
            base.Start();
            if (leftExpression is UnaryExpression && leftExpression.Type == UtilConstants.BoolType && !this.Context.Result.Contains(ExpressionConst.ExpressionReplace))
            {
                this.Context.Result.AppendFormat(" {0} ", ExpressionTool.GetOperator(expression.NodeType));
            }
            base.IsLeft     = false;
            base.Expression = rightExpression;
            base.Start();
            base.IsLeft = null;
            if (lsbs && parameter.ValueIsNull)
            {
                base.Context.Result.Replace(ExpressionConst.ExpressionReplace + parameter.Index, isEqual ? "IS" : "IS NOT");
                base.Context.Result.Replace(ExpressionConst.ExpressionReplace + (parameter.Index + 1), isEqual ? "IS" : "IS NOT");
            }
            else
            {
                base.Context.Result.Replace(ExpressionConst.ExpressionReplace + parameter.Index, operatorValue);
                base.Context.Result.Replace(ExpressionConst.ExpressionReplace + (parameter.Index + 1), operatorValue);
            }
            base.Context.Result.Append(ExpressionConst.RightParenthesis);
            if (parameter.BaseExpression is BinaryExpression && parameter.IsLeft == true)
            {
                base.Context.Result.Append(" " + ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index + " ");
            }
        }
Exemple #16
0
        public ConstantExpressionResolve(ExpressionParameter parameter) : base(parameter)
        {
            var    expression    = base.Expression as ConstantExpression;
            var    isLeft        = parameter.IsLeft;
            object value         = ExpressionTool.GetValue(expression.Value);
            var    baseParameter = parameter.BaseParameter;

            baseParameter.ChildExpression = expression;
            var isSetTempData = baseParameter.CommonTempData.HasValue() && baseParameter.CommonTempData.Equals(CommonTempDataType.Result);

            switch (parameter.Context.ResolveType)
            {
            case ResolveExpressType.SelectSingle:
            case ResolveExpressType.Update:
            case ResolveExpressType.SelectMultiple:
                baseParameter.CommonTempData = value;
                break;

            case ResolveExpressType.WhereSingle:
            case ResolveExpressType.WhereMultiple:
                if (isSetTempData)
                {
                    baseParameter.CommonTempData = value;
                }
                else
                {
                    var parentIsBinary = parameter.BaseParameter.CurrentExpression is BinaryExpression;
                    var parentIsRoot   = parameter.BaseParameter.CurrentExpression is LambdaExpression;
                    var isBool         = value != null && value.GetType() == UtilConstants.BoolType;
                    if (parentIsRoot && isBool)
                    {
                        this.Context.Result.Append(value.ObjToBool() ? this.Context.DbMehtods.True() : this.Context.DbMehtods.False());
                        break;
                    }
                    if (parentIsBinary && isBool)
                    {
                        var isLogicOperator =
                            parameter.BaseExpression.NodeType == ExpressionType.And ||
                            parameter.BaseExpression.NodeType == ExpressionType.AndAlso ||
                            parameter.BaseExpression.NodeType == ExpressionType.Or ||
                            parameter.BaseExpression.NodeType == ExpressionType.OrElse;
                        if (isLogicOperator)
                        {
                            AppendMember(parameter, isLeft, (value.ObjToBool() ? this.Context.DbMehtods.True() : this.Context.DbMehtods.False()));
                            break;
                        }
                    }
                    if (value == null && parentIsBinary)
                    {
                        parameter.BaseParameter.ValueIsNull = true;
                        value = this.Context.DbMehtods.Null();
                    }
                    AppendValue(parameter, isLeft, value);
                }
                break;

            case ResolveExpressType.FieldSingle:
            case ResolveExpressType.FieldMultiple:
            default:
                break;
            }
        }
Exemple #17
0
        private void AppendModel(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item)
        {
            parameter.CommonTempData = CommonTempDataType.Result;
            base.Expression          = item;
            if (item.Type == UtilConstants.DateType && parameter.CommonTempData.ObjToString() == CommonTempDataType.Result.ToString() && item.ToString() == "DateTime.Now.Date")
            {
                parameter.CommonTempData = DateTime.Now.Date;
            }
            else if (IsDateDate(item))
            {
                parameter.CommonTempData = GetNewExpressionValue(item);
            }
            else if (IsDateValue(item))
            {
                parameter.CommonTempData = GetNewExpressionValue(item);
            }
            else if (model.Name == "ToString" && item is ConstantExpression && (item as ConstantExpression).Type.IsEnum())
            {
                parameter.CommonTempData = item.ToString();
            }
            else
            {
                base.Start();
            }
            var methodCallExpressionArgs = new MethodCallExpressionArgs()
            {
                IsMember   = parameter.ChildExpression is MemberExpression && !ExpressionTool.IsConstExpression(parameter.ChildExpression as MemberExpression),
                MemberName = parameter.CommonTempData
            };

            if (methodCallExpressionArgs.IsMember && parameter.ChildExpression != null && parameter.ChildExpression.ToString() == "DateTime.Now")
            {
                methodCallExpressionArgs.IsMember = false;
            }
            var value = methodCallExpressionArgs.MemberName;

            if (methodCallExpressionArgs.IsMember)
            {
                var childExpression = parameter.ChildExpression as MemberExpression;
                if (childExpression.Expression != null && childExpression.Expression is ConstantExpression)
                {
                    methodCallExpressionArgs.IsMember = false;
                }
            }
            if (IsDateDate(item) || IsDateValue(item))
            {
                methodCallExpressionArgs.IsMember = true;
            }
            if (methodCallExpressionArgs.IsMember == false && (item is MethodCallExpression && item.ToString() == "GetDate()") || (item is UnaryExpression && ((UnaryExpression)item).Operand.ToString() == "GetDate()"))
            {
                var parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.MethodConst + this.Context.ParameterIndex;
                this.Context.ParameterIndex++;
                methodCallExpressionArgs.MemberName  = value;
                methodCallExpressionArgs.MemberValue = null;
            }
            else if (methodCallExpressionArgs.IsMember == false)
            {
                var parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.MethodConst + this.Context.ParameterIndex;
                this.Context.ParameterIndex++;
                methodCallExpressionArgs.MemberName  = parameterName;
                methodCallExpressionArgs.MemberValue = value;
                this.Context.Parameters.Add(new DbLiteParameter(parameterName, value));
            }
            model.Args.Add(methodCallExpressionArgs);
            parameter.ChildExpression = null;
        }
Exemple #18
0
        public UnaryExpressionResolve(ExpressionParameter parameter) : base(parameter)
        {
            var oldExpression = base.Expression;
            var expression    = base.Expression as UnaryExpression;
            var baseParameter = parameter.BaseParameter;

            switch (this.Context.ResolveType)
            {
            case ResolveExpressType.WhereSingle:
            case ResolveExpressType.WhereMultiple:
            case ResolveExpressType.FieldSingle:
            case ResolveExpressType.FieldMultiple:
            case ResolveExpressType.SelectSingle:
            case ResolveExpressType.SelectMultiple:
            case ResolveExpressType.ArraySingle:
            case ResolveExpressType.ArrayMultiple:
            case ResolveExpressType.Update:
                var nodeType = expression.NodeType;
                base.Expression = expression.Operand;
                var isMember     = expression.Operand is MemberExpression;
                var isConst      = expression.Operand is ConstantExpression;
                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);
                }
                else if (baseParameter.OperatorValue == "=" && IsNotMember(oldExpression))
                {
                    AppendNotMember(parameter, nodeType);
                }
                else if (baseParameter.OperatorValue == "=" && IsNotParameter(oldExpression))
                {
                    AppendNotParameter(parameter, nodeType);
                }
                else if (base.Expression is BinaryExpression || parameter.BaseExpression is BinaryExpression || baseParameter.CommonTempData.ObjToString() == CommonTempDataType.Append.ToString())
                {
                    Append(parameter, nodeType);
                }
                else if (isMember)
                {
                    MemberLogic(parameter, baseParameter, nodeType);
                }
                else if (isConst)
                {
                    Result(parameter, nodeType);
                }
                else
                {
                    Append(parameter, nodeType);
                }
                break;

            default:
                break;
            }
        }
Exemple #19
0
        public MethodCallExpressionResolve(ExpressionParameter parameter) : base(parameter)
        {
            contextIndex = this.Context.Index;
            var express = base.Expression as MethodCallExpression;

            if (express == null)
            {
                return;
            }
            var    isLeft              = parameter.IsLeft;
            string methodName          = express.Method.Name;
            var    isValidNativeMethod = IsValidNativeMethod(express, methodName);
            List <MethodCallExpressionArgs> appendArgs = null;

            if (MethodTimeMapping.ContainsKey(methodName))
            {
                appendArgs = new List <MethodCallExpressionArgs>();
                var    dateType     = MethodTimeMapping[methodName];
                string paramterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
                appendArgs.Add(new MethodCallExpressionArgs()
                {
                    IsMember = false, MemberName = paramterName, MemberValue = dateType
                });
                this.Context.Parameters.Add(new DbLiteParameter(paramterName, dateType.ToString()));
                this.Context.ParameterIndex++;
                methodName          = "DateAdd";
                isValidNativeMethod = true;
            }
            else if (methodName == "get_Item")
            {
                string paramterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
                this.Context.Parameters.Add(new DbLiteParameter(paramterName, ExpressionTool.DynamicInvoke(express)));
                this.Context.Result.Append(string.Format(" {0} ", paramterName));
                this.Context.ParameterIndex++;
                return;
            }
            else if (methodName == "NewGuid")
            {
                this.Context.Result.Append(this.Context.DbMehtods.GuidNew());
                return;
            }
            else if (IsSubMethod(express, methodName))
            {
                //Check.Exception(!(parameter.BaseExpression is BinaryExpression), "Current expressions are not supported");
                SubResolve subResolve = new SubResolve(express, this.Context, parameter.OppsiteExpression);
                var        appendSql  = subResolve.GetSql();
                if (this.Context.ResolveType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle) || (parameter.BaseParameter != null && parameter.BaseParameter.CommonTempData != null && parameter.BaseParameter.CommonTempData.Equals(CommonTempDataType.Result)))
                {
                    parameter.BaseParameter.CommonTempData = appendSql;
                }
                else
                {
                    base.AppendValue(parameter, isLeft, appendSql);
                }
                return;
            }
            else if (IsIfElse(express, methodName))
            {
                CaseWhenResolve caseResole = new CaseWhenResolve(express, this.Context, parameter.OppsiteExpression);
                var             appendSql  = caseResole.GetSql();
                var             isRoot     = contextIndex == 2 && parameter.BaseExpression == null;
                if (isRoot || (parameter.BaseExpression != null && ExpressionTool.IsLogicOperator(parameter.BaseExpression)))
                {
                    appendSql = appendSql + "=1 ";
                }
                if (this.Context.ResolveType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle, ResolveExpressType.Update))
                {
                    parameter.BaseParameter.CommonTempData = appendSql;
                }
                else
                {
                    base.AppendValue(parameter, isLeft, appendSql);
                }
                return;
            }
            if (IsContainsArray(express, methodName, isValidNativeMethod))
            {
                methodName          = "ContainsArray";
                isValidNativeMethod = true;
            }
            if (isValidNativeMethod)
            {
                NativeExtensionMethod(parameter, express, isLeft, MethodMapping[methodName], appendArgs);
            }
            else
            {
                SqlFuncMethod(parameter, express, isLeft);
            }
        }
Exemple #20
0
 private MemberExpression ResolveValue(ExpressionParameter parameter, ExpressionParameter baseParameter, MemberExpression expression, bool?isLeft, bool isSetTempData, bool isSingle)
 {
     expression = expression.Expression as MemberExpression;
     baseParameter.ChildExpression = expression;
     if (UtilMethods.GetUnderType(expression.Type) == UtilConstants.BoolType && parameter.BaseExpression != null && ExpressionTool.IsLogicOperator(parameter.BaseExpression))
     {
         ResolveBoolLogic(parameter, baseParameter, expression, isLeft, isSetTempData, isSingle);
     }
     else
     {
         ResolveWhereLogic(parameter, baseParameter, expression, isLeft, isSetTempData, isSingle);
     }
     return(expression);
 }
        public NewArrayExpessionResolve(ExpressionParameter parameter) : base(parameter)
        {
            var expression = (NewArrayExpression)base.Expression;

            switch (base.Context.ResolveType)
            {
            case ResolveExpressType.WhereSingle:
            case ResolveExpressType.WhereMultiple:
            case ResolveExpressType.SelectSingle:
            case ResolveExpressType.SelectMultiple:
            case ResolveExpressType.FieldSingle:
            case ResolveExpressType.FieldMultiple:
                try
                {
                    var value         = ExpressionTool.DynamicInvoke(expression);
                    var isLeft        = parameter.IsLeft;
                    var baseParameter = parameter.BaseParameter;
                    var isSetTempData = baseParameter.CommonTempData.HasValue() && baseParameter.CommonTempData.Equals(CommonTempDataType.Result);
                    if (isSetTempData)
                    {
                        baseParameter.CommonTempData = value;
                    }
                    else
                    {
                        var parentIsBinary = parameter.BaseParameter.CurrentExpression is BinaryExpression;
                        var parentIsRoot   = parameter.BaseParameter.CurrentExpression is LambdaExpression;
                        var isBool         = value != null && value.GetType() == UtilConstants.BoolType;
                        if (parentIsRoot && isBool)
                        {
                            this.Context.Result.Append(value.ObjToBool() ? this.Context.DbMehtods.True() : this.Context.DbMehtods.False());
                            break;
                        }
                        if (parentIsBinary && isBool)
                        {
                            var isLogicOperator =
                                parameter.BaseExpression.NodeType == ExpressionType.And ||
                                parameter.BaseExpression.NodeType == ExpressionType.AndAlso ||
                                parameter.BaseExpression.NodeType == ExpressionType.Or ||
                                parameter.BaseExpression.NodeType == ExpressionType.OrElse;
                            if (isLogicOperator)
                            {
                                AppendMember(parameter, isLeft, (value.ObjToBool() ? this.Context.DbMehtods.True() : this.Context.DbMehtods.False()));
                                break;
                            }
                        }
                        if (value == null && parentIsBinary)
                        {
                            parameter.BaseParameter.ValueIsNull = true;
                            value = this.Context.DbMehtods.Null();
                        }
                        AppendValue(parameter, isLeft, value);
                    }
                }
                catch (Exception)
                {
                    Check.ThrowNotSupportedException("NewArrayExpression");
                }
                break;

            case ResolveExpressType.ArraySingle:
                foreach (var item in expression.Expressions)
                {
                    base.Expression = item;
                    base.Start();
                }
                break;

            case ResolveExpressType.Join:
                base.Context.ResolveType = ResolveExpressType.WhereMultiple;
                int i = 0;
                foreach (var item in expression.Expressions)
                {
                    if (item is UnaryExpression)
                    {
                        base.Expression = item;
                        base.Start();
                        if (parameter.CommonTempData is JoinType)
                        {
                            if (i > 0)
                            {
                                base.Context.Result.Append("," + parameter.CommonTempData.ObjToString().Replace(",", UtilConstants.ReplaceCommaKey) + ",");
                            }
                            else
                            {
                                base.Context.Result.Append(parameter.CommonTempData.ObjToString().Replace(",", UtilConstants.ReplaceCommaKey) + ",");
                            }
                            ++i;
                        }
                    }
                }
                break;

            default:
                break;
            }
        }
        private void Update(MemberInitExpression expression, ExpressionParameter parameter)
        {
            int i = 0;

            foreach (MemberBinding binding in expression.Bindings)
            {
                ++i;
                if (binding.BindingType != MemberBindingType.Assignment)
                {
                    throw new NotSupportedException();
                }
                MemberAssignment memberAssignment = (MemberAssignment)binding;
                var type       = expression.Type;
                var memberName = this.Context.GetDbColumnName(type.Name, memberAssignment.Member.Name);
                var item       = memberAssignment.Expression;
                if ((item is MemberExpression) && ((MemberExpression)item).Expression == null)
                {
                    var    paramterValue = ExpressionTool.DynamicInvoke(item);
                    string parameterName = AppendParameter(paramterValue);
                    this.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                }
                else if (IsNotMember(item))
                {
                    if (base.Context.Result.IsLockCurrentParameter == false)
                    {
                        base.Context.Result.CurrentParameter       = parameter;
                        base.Context.Result.IsLockCurrentParameter = true;
                        parameter.IsAppendTempDate();
                        base.Expression = item;
                        base.Expression = (item as UnaryExpression).Operand;
                        base.Start();
                        parameter.IsAppendResult();
                        var result = this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
                        {
                            Args = new List <MethodCallExpressionArgs>()
                            {
                                new MethodCallExpressionArgs()
                                {
                                    IsMember = true, MemberName = parameter.CommonTempData.ObjToString() + "=1"
                                },
                                new MethodCallExpressionArgs()
                                {
                                    IsMember = true, MemberName = AppendParameter(0)
                                },
                                new MethodCallExpressionArgs()
                                {
                                    IsMember = true, MemberName = AppendParameter(1)
                                }
                            }
                        });
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, result));
                        base.Context.Result.CurrentParameter = null;
                    }
                }
                else if (IsNotParameter(item))
                {
                    try
                    {
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, AppendParameter(ExpressionTool.DynamicInvoke(item).ObjToBool())));
                    }
                    catch
                    {
                        throw new NotSupportedException(item.ToString());
                    }
                }
                else if (IsMethod(item))
                {
                    if (item is UnaryExpression)
                    {
                        item = (item as UnaryExpression).Operand;
                    }
                    var callMethod = item as MethodCallExpression;
                    if (MethodTimeMapping.Any(it => it.Key == callMethod.Method.Name) || MethodMapping.Any(it => it.Key == callMethod.Method.Name) || IsExtMethod(callMethod.Method.Name) || IsSubMethod(callMethod) || callMethod.Method.DeclaringType.FullName.StartsWith(UtilConstants.AssemblyName + UtilConstants.Dot))
                    {
                        MethodCall(parameter, memberName, item);
                    }
                    else
                    {
                        var    paramterValue = ExpressionTool.DynamicInvoke(item);
                        string parameterName = AppendParameter(paramterValue);
                        this.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                    }
                }
                else if (IsConst(item) && IsConvert(item) && UtilMethods.IsNullable(item.Type) && UtilMethods.GetUnderType(item.Type) == UtilConstants.BoolType)
                {
                    item = (item as UnaryExpression).Operand;
                    parameter.Context.Result.Append(base.Context.GetEqString(memberName, GetNewExpressionValue(item)));
                }
                else if (IsConst(item))
                {
                    base.Expression = item;
                    base.Start();
                    string parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
                    parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                    this.Context.Parameters.Add(new DbLiteParameter(parameterName, parameter.CommonTempData));
                    this.Context.ParameterIndex++;
                }
                else if (item is MemberExpression)
                {
                    if (base.Context.Result.IsLockCurrentParameter == false)
                    {
                        base.Context.Result.CurrentParameter       = parameter;
                        base.Context.Result.IsLockCurrentParameter = true;
                        parameter.IsAppendTempDate();
                        base.Expression = item;
                        base.Start();
                        parameter.IsAppendResult();
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameter.CommonTempData.ObjToString()));
                        base.Context.Result.CurrentParameter = null;
                    }
                }
                else if (item is BinaryExpression)
                {
                    var result = GetNewExpressionValue(item);
                    this.Context.Result.Append(base.Context.GetEqString(memberName, result));
                }
                else if (item is MemberInitExpression)
                {
                    try
                    {
                        var value         = ExpressionTool.DynamicInvoke(item);
                        var parameterName = AppendParameter(value);
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                    }
                    catch (Exception ex)
                    {
                        throw new NotSupportedException("Not Supported " + item.ToString() + " " + ex.Message);
                    }
                }
                else if (item is NewExpression)
                {
                    try
                    {
                        var value         = ExpressionTool.DynamicInvoke(item);
                        var parameterName = AppendParameter(value);
                        parameter.Context.Result.Append(base.Context.GetEqString(memberName, parameterName));
                    }
                    catch (Exception ex)
                    {
                        throw new NotSupportedException("Not Supported " + item.ToString() + " " + ex.Message);
                    }
                }
            }
        }