Esempio n. 1
0
 public AggregateExpression(string aggregateName, SqlExpression argument, bool isDistinct)
     : base(SqlExpressionType.Aggregate)
 {
     this.AggregateName = aggregateName;
     this.Argument = argument;
     this.IsDistinct = isDistinct;
 }
Esempio n. 2
0
 public UnaryExpression(SqlExpressionType nodeType, SqlExpression operand)
     : base(nodeType)
 {
     switch(nodeType)
     {
         case SqlExpressionType.Exists:
         case SqlExpressionType.IsNull:
         case SqlExpressionType.Negate:
         case SqlExpressionType.Not:
         case SqlExpressionType.UnaryPlus:
             this.Operand = operand;
             break;
         default:
             throw new ArgumentOutOfRangeException(nameof(nodeType));
     }
 }
Esempio n. 3
0
 public UpdateExpression(TableExpression table, SqlExpression where, IEnumerable<ColumnAssignment> assignments)
     : base(SqlExpressionType.Update)
 {
     this.Table = table;
     this.Where = where;
     this.Assignments = assignments.ToReadOnly();
 }
Esempio n. 4
0
 public SelectExpression(
     TableAlias tableAlias,
     IEnumerable<ColumnDeclaration> columns,
     SqlExpression from,
     SqlExpression where,
     IEnumerable<OrderByDeclaration> orderBy,
     IEnumerable<SqlExpression> groupBy
     )
     : this(tableAlias, columns, from, where, orderBy, groupBy, null, null, false)
 {
 }
Esempio n. 5
0
 public SelectExpression(
     TableAlias tableAlias,
     IEnumerable<ColumnDeclaration> columns,
     SqlExpression from,
     SqlExpression where
     )
     : this(tableAlias, columns, from, where, null, null)
 {
 }
Esempio n. 6
0
 public static SqlExpression Rewrite(SqlExpression expression)
 {
     return new OrderByRewriter().Visit(expression);
 }
Esempio n. 7
0
 public BinaryExpression(SqlExpressionType nodeType, SqlExpression left, SqlExpression right)
     : base(nodeType)
 {
     switch(nodeType)
     {
         case SqlExpressionType.Add:
         case SqlExpressionType.Subtract:
         case SqlExpressionType.Multiply:
         case SqlExpressionType.Divide:
         case SqlExpressionType.Modulo:
         case SqlExpressionType.And:
         case SqlExpressionType.Or:
         case SqlExpressionType.LessThan:
         case SqlExpressionType.GreaterThan:
         case SqlExpressionType.Equal:
         case SqlExpressionType.NotEqual:
         case SqlExpressionType.RightShift:
         case SqlExpressionType.LeftShift:
         case SqlExpressionType.ExclusiveOr:
             this.Left = left;
             this.Right = right;
             break;
         default:
             throw new ArgumentOutOfRangeException(nameof(nodeType));
     }
 }
Esempio n. 8
0
 public InExpression(SqlExpression expression, IEnumerable<SqlExpression> values)
     : base(SqlExpressionType.In)
 {
     this.Expression = expression;
     this.Values = values.ToReadOnly();
 }
Esempio n. 9
0
 public JoinExpression(JoinType joinType, SqlExpression left, SqlExpression right, SqlExpression condition)
     : base(SqlExpressionType.Join)
 {
     this.JoinType = joinType;
     this.Left = left;
     this.Right = right;
     this.Condition = condition;
 }
Esempio n. 10
0
 public DeleteExpression(TableExpression table, SqlExpression where)
     : base(SqlExpressionType.Delete)
 {
     this.Table = table;
     this.Where = where;
 }
Esempio n. 11
0
 public InExpression(SqlExpression expression, SelectExpression select)
     : base(SqlExpressionType.In)
 {
     this.Expression = expression;
     this.Select = select;
 }
Esempio n. 12
0
 public ConditionalExpression(SqlExpression test, SqlExpression ifTrue, SqlExpression ifFalse)
     : base(SqlExpressionType.Conditional)
 {
     this.Test = test;
     this.IfTrue = ifTrue;
     this.IfFalse = ifFalse;
 }
Esempio n. 13
0
 public ColumnDeclaration(string declaredName, SqlExpression expression)
 {
     this.DeclaredName = declaredName;
     this.Expression = expression;
 }
Esempio n. 14
0
 public ColumnAssignment(ColumnExpression column, SqlExpression expression)
 {
     this.Column = column;
     this.Expression = expression;
 }
Esempio n. 15
0
 protected override SqlExpression VisitSource(SqlExpression expr)
 {
     switch(expr.NodeType)
     {
         case SqlExpressionType.Table:
             this.Visit(expr);
             break;
         case SqlExpressionType.Select:
             SelectExpression select = (SelectExpression)expr;
             this.Write("(");
             this.NewLine(Indentation.Inner);
             this.Visit(select);
             this.NewLine(Indentation.Outer);
             this.Write(") " + GetAliasName(select.TableAlias) + " ");
             break;
         case SqlExpressionType.Join:
             this.Visit(expr);
             break;
         default:
             throw new ArgumentException("Invalid Source!", nameof(expr));
     }
     return expr;
 }
Esempio n. 16
0
 public OrderByDeclaration(OrderType orderType, SqlExpression expression)
 {
     this.OrderType = orderType;
     this.Expression = expression;
 }
Esempio n. 17
0
 public static FormatResult Format(SqlExpression expression)
 {
     SqlFormatter formatter = new SqlFormatter();
     formatter.Visit(expression);
     return new FormatResult() { SqlText = formatter.sb.ToString(), Parameters = formatter.parameters };
 }
Esempio n. 18
0
 public SelectExpression(
     TableAlias tableAlias,
     IEnumerable<ColumnDeclaration> columns,
     SqlExpression from,
     SqlExpression where,
     IEnumerable<OrderByDeclaration> orderBy,
     IEnumerable<SqlExpression> groupBy,
     int? skip,
     int? take,
     bool isDistinct 
     )
     : base(SqlExpressionType.Select, tableAlias)
 {
     this.Columns = columns.ToReadOnly();
     this.From = from;
     this.Where = where;
     this.OrderBy = orderBy.ToReadOnly();
     this.GroupBy = groupBy.ToReadOnly();
     this.Skip = skip;
     this.Take = take;
     this.IsDistinct = isDistinct;
 }
Esempio n. 19
0
 public static HashSet<TableAlias> Gather(SqlExpression source)
 {
     DeclaredAliasGatherer gatherer = new DeclaredAliasGatherer();
     gatherer.Visit(source);
     return gatherer.aliases;
 }
Esempio n. 20
0
 public BetweenExpression(SqlExpression expression, SqlExpression lower, SqlExpression upper)
     : base(SqlExpressionType.Between)
 {
     this.Expression = expression;
     this.Lower = lower;
     this.Upper = upper;
 }