Ejemplo n.º 1
0
 public void Add(Column column)
 {
     this.Parameters.Add(column);
 }
Ejemplo n.º 2
0
 public OrderCondition(Column column, string order)
 {
     this.Column = column;
     this.Order = order;
 }
Ejemplo n.º 3
0
 public OrderCondition(Column column, string order)
 {
     this.Column = column;
     this.Order  = order;
 }
Ejemplo n.º 4
0
 public string ToSql(SqlGenerator generator)
 {
     return(string.Format("{0} {1}", Column.ToSql(generator), Order));
 }
Ejemplo n.º 5
0
 public void Add(Column column)
 {
     this.Parameters.Add(column);
 }
        private void ParseMethodMax(MethodCallExpression node)
        {
            var column = new FunctionColumn();
            column.Formatter = "Max({0})";

            var paramVisitor = new MemberExpressionVisitor(Context);
            paramVisitor.Visit(node.Arguments[1]);
            column.Add(paramVisitor.Column);
            this.Column = column;
        }
        private void ParseMethodCount(MethodCallExpression node)
        {
            var column = new FunctionColumn();
            column.Formatter = "Count(*)";

            //var paramVisitor = new MemberExpressionVisitor(Context);
            //paramVisitor.Visit(node.Arguments[0]);
            //column.Add(paramVisitor.Column);
            this.Column = column;
            this.Column.Alias = (node.Arguments[0] as ParameterExpression).Name;
        }
        private void ParseMethodContains(MethodCallExpression node)
        {
            var column = new FunctionColumn();
            var objectVisitor = new MemberExpressionVisitor(Context);
            var paramVisitor = new MemberExpressionVisitor(Context);
            if (node.Object != null && (node.Object.NodeType == ExpressionType.MemberAccess || node.Object.NodeType == ExpressionType.Constant))
            {
                objectVisitor.Visit(node.Object);

                paramVisitor.Visit(node.Arguments[0]);

            }
            else
            {
                objectVisitor.Visit(node.Arguments[1]);

                paramVisitor.Visit(node.Arguments[0]);
            }

            if (objectVisitor.Column.Type == typeof(string))
            {
                column.Formatter = "LOCATE({1}, {0}) > 0";
            }
            else
            {
                column.Formatter = "{0} in {1}";
            }
            column.Add(objectVisitor.Column);
            column.Add(paramVisitor.Column);
            this.Column = column;
        }
 protected override Expression VisitMethodCall(MethodCallExpression node)
 {
     if (!node.IsConstant())
     {
         switch (node.Method.Name)
         {
             case "Contains":
                 ParseMethodContains(node);
                 break;
             case "Count":
                 ParseMethodCount(node);
                 break;
             case "Max":
                 ParseMethodMax(node);
                 break;
         }
     }
     else
     {
         var objectMember = Expression.Convert(node, typeof(object));
         var getterLambda = Expression.Lambda<Func<object>>(objectMember);
         var getter = getterLambda.Compile()();
         this.Column = new ParameterColumn(this.Context.AddParameter(getter)) { Type = node.Type };
     }
     return node;
 }