ColumnProjection is a visitor that splits an expression representing the result of a query into two parts, a list of column declarations of expressions that must be evaluated on the server and a projector expression that describes how to combine the columns back into the result object
Наследование: Signum.Engine.Linq.DbExpressionVisitor
Пример #1
0
        static internal ProjectedColumns ProjectColumns(Expression projector, Alias newAlias, bool isGroupKey = false, bool selectTrivialColumns = false)
        {
            var candidates = DbExpressionNominator.Nominate(projector, out Expression newProj, isGroupKey: isGroupKey);

            ColumnProjector cp = new ColumnProjector(candidates, newAlias, selectTrivialColumns);

            Expression e = cp.Visit(newProj);

            return(new ProjectedColumns(e, cp.generator.Columns.NotNull().ToReadOnly()));
        }
Пример #2
0
        static internal ProjectedColumns ProjectColumns(Expression projector, Alias newAlias, bool isGroupKey = false, bool selectTrivialColumns = false)
        {
            Expression newProj;
            var candidates = DbExpressionNominator.Nominate(projector, out newProj, isGroupKey: isGroupKey);

            ColumnProjector cp = new ColumnProjector
            {
                newAlias = newAlias,
                candidates = candidates,
                projectTrivialColumns = selectTrivialColumns
            };

            Expression e = cp.Visit(newProj);

            return new ProjectedColumns(e, cp.generator.Columns.ToReadOnly());
        }
Пример #3
0
        protected internal override Expression VisitProjection(ProjectionExpression proj)
        {
            Expression       projector;
            SelectExpression select = proj.Select;

            using (binder.SetCurrentSource(proj.Select))
                projector = this.Visit(proj.Projector);

            Alias            alias = binder.aliasGenerator.NextSelectAlias();
            ProjectedColumns pc    = ColumnProjector.ProjectColumns(projector, alias);

            projector = pc.Projector;

            select = new SelectExpression(alias, false, null, pc.Columns, select, null, null, null, 0);

            if (projector != proj.Projector)
            {
                return(new ProjectionExpression(select, projector, proj.UniqueFunction, proj.Type));
            }

            return(proj);
        }