Пример #1
0
        protected virtual Expression VisitOuterJoined(DbOuterJoinedExpression outer)
        {
            var test       = this.Visit(outer.Test);
            var expression = this.Visit(outer.Expression);

            return(this.UpdateOuterJoined(outer, test, expression));
        }
Пример #2
0
        protected DbOuterJoinedExpression UpdateOuterJoined(DbOuterJoinedExpression outer, Expression test, Expression expression)
        {
            if (test != outer.Test || expression != outer.Expression)
            {
                return(new DbOuterJoinedExpression(test, expression));
            }

            return(outer);
        }
Пример #3
0
        protected virtual Expression VisitOuterJoined(DbOuterJoinedExpression outer)
        {
            this.Write("Outer(");
            this.WriteLine(Indentation.Inner);
            this.Visit(outer.Test);
            this.Write(", ");
            this.WriteLine(Indentation.Same);
            this.Visit(outer.Expression);
            this.WriteLine(Indentation.Outer);
            this.Write(")");

            return(outer);
        }
        public static DbProjectionExpression AddOuterJoinTest(this DbProjectionExpression proj, QueryLanguage language, Expression expression)
        {
            var colName   = proj.Select.Columns.GetAvailableColumnName("Test");
            var colType   = language.TypeSystem.GetColumnType(expression.Type);
            var newSource = proj.Select.AddColumn(new DbColumnDeclaration(colName, expression, colType));

            var newProjector = new DbOuterJoinedExpression
                               (
                new DbColumnExpression(expression.Type, colType, newSource.Alias, colName),
                proj.Projector
                               );

            return(new DbProjectionExpression(newSource, newProjector, proj.Aggregator));
        }
Пример #5
0
        protected override Expression VisitOuterJoined(DbOuterJoinedExpression outer)
        {
            var expr   = this.Visit(outer.Expression);
            var column = outer.Test as DbColumnExpression;

            if (this.scope.TryGetValue(column, out ParameterExpression reader, out int iOrdinal))
            {
                return(Expression.Condition
                       (
                           Expression.Call(reader, "IsDbNull", null, Expression.Constant(iOrdinal)),
                           Expression.Constant(TypeHelper.GetDefault(outer.Type), outer.Type),
                           expr
                       ));
            }

            return(expr);
        }