/// <summary> /// Modifies a projector that would be understandable by the columns mapping process. /// </summary> /// <param name="projector">Projector.</param> /// <returns>A projector that can be used by the columns mapping process for discover the DataTable columns.</returns> private LambdaExpression ShapeProjector(LambdaExpression projector) { // Rewrites an projection of the form p => p into a new projection // that uses the new operator (explicit projection): p => new {p.UnitPrice, p.InStock} var implicitProjectionRewritter = new ImplicitProjectionRewritter(); projector = (LambdaExpression)implicitProjectionRewritter.Rewrite(projector); // Evaluates any subtree that do not reference the projector's parameter var partialEvaluator = new PartialEvaluator(); projector = (LambdaExpression)partialEvaluator.Evaluate(projector); // Evalatues any ColumnSettings object within the projection var columnSettingsEvaluator = new ColumnSettingsEvaluator(); projector = (LambdaExpression)columnSettingsEvaluator.Evaluate(projector); // Rewrites a projection of the form p => p.Member into a new projection // that wraps the member access as a ColumnSettings var memberAccessProjRewritter = new SingleMemberProjectionRewritter(); projector = (LambdaExpression)memberAccessProjRewritter.Rewrite(projector); var projectionValidator = new ProjectionValidator(); projectionValidator.Validate(projector); // Marks as column any subtree that's not a NewExpression var columnExpressionsMapper = new ColumnExpressionMapper(); projector = (LambdaExpression)columnExpressionsMapper.Map(projector); return(projector); }