Ejemplo n.º 1
0
        private static string VisitCore(BinaryExpression bin, IOperatorResolverList lst)
        {
            if (bin.Left.NodeType == ExpressionType.Constant && ((ConstantExpression)bin.Left).Value == null ||
                bin.Right.NodeType == ExpressionType.Constant && ((ConstantExpression)bin.Right).Value == null)
            {
                var openParen = "(";
                if (bin.NodeType == ExpressionType.NotEqual)
                {
                    openParen = "(NOT ";
                }
                if (bin.Right.NodeType == ExpressionType.Constant)
                {
                    return(openParen + Visit(bin.Left, lst) + " IS NULL) ");
                }
                return(openParen + Visit(bin.Right, lst) + " IS NULL) ");
            }

            var lvalue = Visit(bin.Left, lst);
            var op     = lst.GetOperatorFor(bin.NodeType);
            var rvalue = Visit(bin.Right, lst);

            if (rvalue.Trim() == "NULL" && op.Trim() == "=")
            {
                op = " IS ";
            }
            return("(" + lvalue + op + rvalue + ")");
        }
Ejemplo n.º 2
0
 public static string VisitCore(UnaryExpression expr, IOperatorResolverList lst)
 {
     if (expr.NodeType == ExpressionType.Convert)
     {
         var mem = (MemberExpression)expr.Operand;
         return(mem.GetValue().FormatValue());
     }
     if (expr.NodeType == ExpressionType.Not)
     {
         if (expr.Operand.NodeType == ExpressionType.Call)
         {
             var meth = (MethodCallExpression)expr.Operand;
             return(meth.ParseContainsCall(" NOT"));
         }
         return("");
     }
     return("");
 }
Ejemplo n.º 3
0
 public static string VisitCore(MemberExpression memberExp, IOperatorResolverList lst)
 {
     if (memberExp.Expression != null
         &&
         (memberExp.Expression.NodeType == ExpressionType.Constant ||
          memberExp.Expression.NodeType == ExpressionType.MemberAccess)
         )
     {
         return(string.Format(" {0} ", memberExp.GetValue().FormatValue()));
     }
     if (
         memberExp.Expression != null &&
         memberExp.Expression.NodeType == ExpressionType.Parameter)
     {
         return(string.Format(" {0} ", memberExp.GetAttribute()));
     }
     if (memberExp.Expression == null)
     {
         return(string.Format(" {0} ", get_value(memberExp)));
     }
     return("");
 }
Ejemplo n.º 4
0
        private static string VisitCore(MethodCallExpression method, IOperatorResolverList lst)
        {
            if (method.Method.Name == "IsNullOrEmpty")
            {
                return(" IS NULL ");
            }

            if (method.Method.Name == "Trim")
            {
                var argMember = (MemberExpression)method.Arguments[0];
                var parm      = argMember.GetAttribute();

                return(string.Format(" IsNull({0}, '') = '' ", parm));
            }
            if (method.Method.Name == "Contains")
            {
                return(method.ParseContainsCall(""));
            }
            if (method.Method.Name == "Trim")
            {
                return(method.ParseTrimCall());
            }
            return("");
        }
Ejemplo n.º 5
0
 public static string VisitCore(ConstantExpression constant, IOperatorResolverList lst)
 {
     return(string.Format(" {0} ", constant.Value.FormatValue()));
 }
Ejemplo n.º 6
0
        private static string Visit(Expression expression, IOperatorResolverList lst)
        {
            dynamic dynamicExpression = expression;

            return(VisitCore(dynamicExpression, lst));
        }