示例#1
0
        protected virtual Expression VisitOuterJoined(OuterJoinedExpression outer)
        {
            Expression test       = Visit(outer.Test);
            Expression expression = Visit(outer.Expression);

            return(UpdateOuterJoined(outer, test, expression));
        }
示例#2
0
        public virtual ProjectionExpression AddOuterJoinTest(ProjectionExpression proj)
        {
            Expression       test    = GetOuterJoinTest(proj.Select);
            SelectExpression select  = proj.Select;
            ColumnExpression testCol = null;

            // look to see if test expression exists in columns already
            foreach (ColumnDeclaration col in select.Columns)
            {
                if (test.Equals(col.Expression))
                {
                    QueryType colType = TypeSystem.GetColumnType(test.Type);
                    testCol = new ColumnExpression(test.Type, colType, select.Alias, col.Name);
                    break;
                }
            }
            if (testCol == null)
            {
                // add expression to projection
                testCol = test as ColumnExpression;
                string colName = (testCol != null) ? testCol.Name : "Test";
                colName = proj.Select.Columns.GetAvailableColumnName(colName);
                QueryType colType = TypeSystem.GetColumnType(test.Type);
                select  = select.AddColumn(new ColumnDeclaration(colName, test, colType));
                testCol = new ColumnExpression(test.Type, colType, select.Alias, colName);
            }
            var newProjector = new OuterJoinedExpression(testCol, proj.Projector);

            return(new ProjectionExpression(select, newProjector, proj.Aggregator));
        }
示例#3
0
 protected OuterJoinedExpression UpdateOuterJoined(OuterJoinedExpression outer, Expression test, Expression expression)
 {
     if (test != outer.Test || expression != outer.Expression)
     {
         return(new OuterJoinedExpression(test, expression));
     }
     return(outer);
 }
示例#4
0
        public static ProjectionExpression AddOuterJoinTest(this ProjectionExpression proj, QueryLanguage language, Expression expression)
        {
            string           colName      = proj.Select.Columns.GetAvailableColumnName("Test");
            QueryType        colType      = language.TypeSystem.GetColumnType(expression.Type);
            SelectExpression newSource    = proj.Select.AddColumn(new ColumnDeclaration(colName, expression, colType));
            Expression       newProjector = new OuterJoinedExpression(new ColumnExpression(expression.Type, colType, newSource.Alias, colName), proj.Projector);

            return(new ProjectionExpression(newSource, newProjector, proj.Aggregator));
        }
示例#5
0
 protected virtual Expression VisitOuterJoined(OuterJoinedExpression outer)
 {
     Write("Outer(");
     WriteLine(Indentation.Inner);
     Visit(outer.Test);
     Write(", ");
     WriteLine(Indentation.Same);
     Visit(outer.Expression);
     WriteLine(Indentation.Outer);
     Write(")");
     return(outer);
 }
示例#6
0
        protected override Expression VisitOuterJoined(OuterJoinedExpression outer)
        {
            Expression          expr   = Visit(outer.Expression);
            var                 column = (ColumnExpression)outer.Test;
            ParameterExpression reader;
            int                 iOrdinal;

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