/// <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; }
private QueryBinder(MetaMapping mapping, Expression root) { this.mapping = mapping; this.map = new Dictionary<ParameterExpression, Expression>(); this.groupByMap = new Dictionary<Expression, GroupByInfo>(); this.root = root; }
public static Expression Bind(MetaMapping mapping, Expression expression) { return new RelationshipBinder(mapping).Visit(expression); }
private RelationshipBinder(MetaMapping mapping) { this.mapping = mapping; }
/// <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); }
public static Expression Include(MetaMapping mapping, QueryPolicy policy, Expression expression) { return new RelationshipIncluder(mapping, policy).Visit(expression); }
private RelationshipIncluder(MetaMapping mapping, QueryPolicy policy) { this.mapping = mapping; this.policy = policy; }
public static Expression Bind(MetaMapping mapping, Expression expression) { return new QueryBinder(mapping, expression).Visit(expression); }