Example #1
0
 internal SetOperatorExpression(SetOperator @operator, SourceWithAliasExpression left, SourceWithAliasExpression right, Alias alias)
     : base(DbExpressionType.SetOperator, alias)
 {
     this.Operator = @operator;
     this.Left     = Validate(left, nameof(left));
     this.Right    = Validate(right, nameof(right));
 }
Example #2
0
 public InsertSelectExpression(ITable table, bool useHistoryTable, SourceWithAliasExpression source, IEnumerable <ColumnAssignment> assigments)
     : base(DbExpressionType.InsertSelect)
 {
     this.Table           = table;
     this.UseHistoryTable = useHistoryTable;
     this.Assigments      = assigments.ToReadOnly();
     this.Source          = source;
 }
Example #3
0
 private SourceWithAliasExpression VisitSetOperatorPart(SourceWithAliasExpression part, List <ColumnExpression> askedColumns)
 {
     using (NewScope())
     {
         CurrentScope.AddRange(askedColumns.ToDictionary(c => new ColumnExpression(c.Type, part.Alias, c.Name), c => (ColumnExpression?)null));
         return((SourceWithAliasExpression)Visit(part));
     }
 }
Example #4
0
 public DeleteExpression(ITable table, bool useHistoryTable, SourceWithAliasExpression source, Expression?where)
     : base(DbExpressionType.Delete)
 {
     this.Table           = table;
     this.UseHistoryTable = useHistoryTable;
     this.Source          = source;
     this.Where           = where;
 }
Example #5
0
 public UpdateExpression(ITable table, bool useHistoryTable, SourceWithAliasExpression source, Expression where, IEnumerable <ColumnAssignment> assigments)
     : base(DbExpressionType.Update)
 {
     this.Table           = table;
     this.UseHistoryTable = useHistoryTable;
     this.Assigments      = assigments.ToReadOnly();
     this.Source          = source;
     this.Where           = where;
 }
    protected internal virtual Expression VisitSetOperator(SetOperatorExpression set)
    {
        SourceWithAliasExpression left  = (SourceWithAliasExpression)this.VisitSource(set.Left) !;
        SourceWithAliasExpression right = (SourceWithAliasExpression)this.VisitSource(set.Right) !;

        if (left != set.Left || right != set.Right)
        {
            return(new SetOperatorExpression(set.Operator, left, right, set.Alias));
        }
        return(set);
    }
Example #7
0
    protected internal override Expression VisitSetOperator(SetOperatorExpression set)
    {
        SourceWithAliasExpression left  = (SourceWithAliasExpression)this.VisitSource(set.Left) !;
        SourceWithAliasExpression right = (SourceWithAliasExpression)this.VisitSource(set.Right) !;
        Alias newAlias = aliasMap.TryGetC(set.Alias) ?? set.Alias;

        if (left != set.Left || right != set.Right || newAlias != set.Alias)
        {
            return(new SetOperatorExpression(set.Operator, left, right, newAlias));
        }
        return(set);
    }
Example #8
0
        static SourceWithAliasExpression Validate(SourceWithAliasExpression exp, string name)
        {
            if (exp == null)
            {
                throw new ArgumentNullException(name);
            }

            if (exp is TableExpression || exp is SqlTableValuedFunctionExpression)
            {
                throw new ArgumentException($"{name} should not be a {exp.GetType().Name}");
            }

            return(exp);
        }
Example #9
0
    protected internal override Expression VisitSetOperator(SetOperatorExpression set)
    {
        List <ColumnExpression> askedColumns = CurrentScope.Keys.Where(k => k.Alias == set.Alias).ToList();

        SourceWithAliasExpression left  = VisitSetOperatorPart(set.Left, askedColumns);
        SourceWithAliasExpression right = VisitSetOperatorPart(set.Right, askedColumns);

        CurrentScope.SetRange(askedColumns, askedColumns);

        if (left != set.Left || right != set.Right)
        {
            return(new SetOperatorExpression(set.Operator, left, right, set.Alias));
        }

        return(set);
    }
Example #10
0
 private SourceWithAliasExpression VisitSetOperatorPart(SourceWithAliasExpression part, List<ColumnExpression> askedColumns)
 {
     using (NewScope())
     {
         CurrentScope.AddRange(askedColumns.ToDictionary(c => new ColumnExpression(c.Type, part.Alias, c.Name), c => (Expression)null));
         return (SourceWithAliasExpression)Visit(part);
     }
 }
Example #11
0
 void VisitSetPart(SourceWithAliasExpression source)
 {
     if (source is SelectExpression)
     {
         this.Indent(Indentation.Inner);
         VisitSelect((SelectExpression)source);
         this.Indent(Indentation.Outer);
     }
     else if (source is SetOperatorExpression)
     {
         VisitSetOperator((SetOperatorExpression)source);
     }
     else
         throw new InvalidOperationException("{0} not expected in SetOperatorExpression".Formato(source.NiceToString()));
 }