コード例 #1
0
        /// <summary>
        /// Provides policy specific query translations.  This is where choices about inclusion of related objects and how
        /// heirarchies are materialized affect the definition of the queries.
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public virtual Expression Translate(MetaMapping mapping, Expression expression)
        {
            // add included relationships to client projection
            expression = RelationshipIncluder.Include(mapping, this, expression);

            expression = UnusedColumnRemover.Remove(expression);
            expression = RedundantColumnRemover.Remove(expression);
            expression = RedundantSubqueryRemover.Remove(expression);
            expression = RedundantJoinRemover.Remove(expression);

            // convert any singleton (1:1 or n:1) projections into server-side joins (cardinality is preserved)
            expression = SingletonProjectionRewriter.Rewrite(mapping.Language, expression);

            expression = UnusedColumnRemover.Remove(expression);
            expression = RedundantColumnRemover.Remove(expression);
            expression = RedundantSubqueryRemover.Remove(expression);
            expression = RedundantJoinRemover.Remove(expression);

            // convert projections into client-side joins
            expression = ClientJoinedProjectionRewriter.Rewrite(mapping.Language, expression);

            expression = UnusedColumnRemover.Remove(expression);
            expression = RedundantColumnRemover.Remove(expression);
            expression = RedundantSubqueryRemover.Remove(expression);
            expression = RedundantJoinRemover.Remove(expression);

            return expression;
        }
コード例 #2
0
 private QueryBinder(MetaMapping mapping, Expression root)
 {
     this.mapping = mapping;
     this.map = new Dictionary<ParameterExpression, Expression>();
     this.groupByMap = new Dictionary<Expression, GroupByInfo>();
     this.root = root;
 }
コード例 #3
0
 public static Expression Bind(MetaMapping mapping, Expression expression)
 {
     return new RelationshipBinder(mapping).Visit(expression);
 }
コード例 #4
0
 private RelationshipBinder(MetaMapping mapping)
 {
     this.mapping = mapping;
 }
コード例 #5
0
 /// <summary>
 /// Converts a query into an execution plan.  The plan is an function that executes the query and builds the
 /// resulting objects.
 /// </summary>
 /// <param name="projection"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public virtual Expression BuildExecutionPlan(MetaMapping mapping, Expression query, Expression provider)
 {
     return ExecutionBuilder.Build(mapping, this, query, provider);
 }
コード例 #6
0
 public static Expression Include(MetaMapping mapping, QueryPolicy policy, Expression expression)
 {
     return new RelationshipIncluder(mapping, policy).Visit(expression);
 }
コード例 #7
0
 private RelationshipIncluder(MetaMapping mapping, QueryPolicy policy)
 {
     this.mapping = mapping;
     this.policy = policy;
 }
コード例 #8
0
 public static Expression Bind(MetaMapping mapping, Expression expression)
 {
     return new QueryBinder(mapping, expression).Visit(expression);
 }