Example #1
0
 protected SqlFormatter(QueryLanguage language, bool forDebug)
 {
     this.language = language;
     this.sb = new StringBuilder();
     this.aliases = new Dictionary<IdentifiableAlias, string>();
     this.forDebug = forDebug;
 }
Example #2
0
 protected QueryBinder(QueryMapper mapper, Expression root)
 {
     this.mapper = mapper;
     this.language = mapper.Translator.Linguist.Language;
     this.map = new Dictionary<ParameterExpression, Expression>();
     this.groupByMap = new Dictionary<Expression, GroupByInfo>();
     this.root = root;
     this.repoType = mapper.Mapping.RepositoryType;
 }
        public static SelectExpression AddRedundantSelect(this SelectExpression sel, QueryLanguage language, IdentifiableAlias newAlias)
        {
            var newFields =
                from d in sel.Fields
                let qt = (d.Expression is FieldExpression) ? ((FieldExpression)d.Expression).QueryType : language.TypeSystem.GetStorageType(d.Expression.Type)
                select new FieldDeclaration(d.Name, new FieldExpression(d.Expression.Type, qt, newAlias, d.Name), qt);

            var newFrom = new SelectExpression(newAlias, sel.Fields, sel.From, sel.Where, sel.OrderBy, sel.GroupBy, sel.IsDistinct, sel.Skip, sel.Take, sel.IsReverse);
            return new SelectExpression(sel.Alias, newFields, newFrom, null, null, null, false, null, null, false);
        }
 public static ProjectionExpression AddOuterJoinTest(this ProjectionExpression proj, QueryLanguage language, Expression expression)
 {
     string colName = proj.Select.Fields.GetAvailableFieldName("Test");
     var colType = language.TypeSystem.GetStorageType(expression.Type);
     SelectExpression newSource = proj.Select.AddField(new FieldDeclaration(colName, expression, colType));
     Expression newProjector =
         new OuterJoinedExpression(
             new FieldExpression(expression.Type, colType, newSource.Alias, colName),
             proj.Projector
             );
     return new ProjectionExpression(newSource, newProjector, proj.Aggregator);
 }
Example #5
0
 public DataProvider(IRepository repository, QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
 {
     if (language == null)
         throw new InvalidOperationException("Language not specified");
     if (mapping == null)
         throw new InvalidOperationException("Mapping not specified");
     if (policy == null)
         throw new InvalidOperationException("Policy not specified");
     this._language = language;
     this._mapping = mapping;
     this._policy = policy;
     this.Repository = repository;
 }
Example #6
0
 private FieldProjector(QueryLanguage language, Expression expression, IEnumerable<FieldDeclaration> existingFields, IdentifiableAlias newAlias, IEnumerable<IdentifiableAlias> existingAliases)
 {
     this.language = language;
     this.newAlias = newAlias;
     this.existingAliases = new HashSet<IdentifiableAlias>(existingAliases);
     this.map = new Dictionary<FieldExpression, FieldExpression>();
     if (existingFields != null)
     {
         this.fields = new List<FieldDeclaration>(existingFields);
         this.fieldNames = new HashSet<string>(existingFields.Select(c => c.Name));
     }
     else
     {
         this.fields = new List<FieldDeclaration>();
         this.fieldNames = new HashSet<string>();
     }
     this.candidates = Nominator.Nominate(language, expression);
 }
Example #7
0
 private Nominator(QueryLanguage language)
 {
     this.language = language;
     this.candidates = new HashSet<Expression>();
     this.isBlocked = false;
 }
 public static Expression Rewrite(QueryPolicy policy, QueryLanguage language, Expression expression)
 {
     return new ClientJoinedProjectionRewriter(policy, language).Visit(expression);
 }
 private ClientJoinedProjectionRewriter(QueryPolicy policy, QueryLanguage language)
 {
     this.policy = policy;
     this.language = language;
 }
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return new SingletonProjectionRewriter(language).Visit(expression);
 }
 private SingletonProjectionRewriter(QueryLanguage language)
 {
     this.language = language;
 }
Example #12
0
 protected OAggregateRewriter(QueryLanguage language, Expression expr)
     : base(language, expr)
 {
 }
Example #13
0
 public static ProjectedFields ProjectFields(QueryLanguage language, Expression expression, IEnumerable<FieldDeclaration> existingFields, IdentifiableAlias newAlias, IEnumerable<IdentifiableAlias> existingAliases)
 {
     FieldProjector projector = new FieldProjector(language, expression, existingFields, newAlias, existingAliases);
     Expression expr = projector.Visit(expression);
     return new ProjectedFields(expr, projector.fields.AsReadOnly());
 }
Example #14
0
 protected OQueryFormatter(QueryLanguage language, bool forDebug)
     : base(language, forDebug)
 {
 }
Example #15
0
 public QueryLinguist(QueryLanguage language, QueryTranslator translator)
 {
     this.language = language;
     this.translator = translator;
 }
Example #16
0
 public static Expression Rewrite(QueryLanguage language, Expression expr)
 {
     return new AggregateRewriter(language, expr).Visit(expr);
 }
Example #17
0
 protected AggregateRewriter(QueryLanguage language, Expression expr)
 {
     this.language = language;
     this.map = new Dictionary<AggregateSubqueryExpression, Expression>();
     this.lookup = Gather(expr).ToLookup(a => a.GroupByAlias);
 }
Example #18
0
 public static string WriteToString(QueryLanguage language, Expression expression)
 {
     StringWriter sw = new StringWriter();
     Write(sw, language, expression);
     return sw.ToString();
 }
Example #19
0
 public static void Write(TextWriter writer, QueryLanguage language, Expression expression)
 {
     new DbExpressionWriter(writer, language).Visit(expression);
 }
Example #20
0
 protected DbExpressionWriter(TextWriter writer, QueryLanguage language)
     : base(writer)
 {
     this.language = language;
 }
Example #21
0
 internal static HashSet<Expression> Nominate(QueryLanguage language, Expression expression)
 {
     Nominator nominator = new Nominator(language);
     nominator.Visit(expression);
     return nominator.candidates;
 }
Example #22
0
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return new CrossApplyRewriter(language).Visit(expression);
 }
Example #23
0
 public QueryTranslator(QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
 {
     this.linguist = language.CreateLinguist(this);
     this.mapper = mapping.CreateMapper(this);
     this.police = policy.CreatePolice(this);
 }
Example #24
0
 public static ProjectedFields ProjectFields(QueryLanguage language, Expression expression, IEnumerable<FieldDeclaration> existingFields, IdentifiableAlias newAlias, params IdentifiableAlias[] existingAliases)
 {
     return ProjectFields(language, expression, existingFields, newAlias, (IEnumerable<IdentifiableAlias>)existingAliases);
 }
Example #25
0
 public static new Expression Parameterize(QueryLanguage language, Expression expression)
 {
     return new OParameterizer((OQueryLanguage)language).Visit(expression);
 }
Example #26
0
 protected RelationshipBinder(QueryMapper mapper)
 {
     this.mapper = mapper;
     this.mapping = mapper.Mapping;
     this.language = mapper.Translator.Linguist.Language;
 }
Example #27
0
 public OQueryLinguist(QueryLanguage language, QueryTranslator translator)
     : base(language, translator)
 {
 }
Example #28
0
 protected OQueryFormatter(QueryLanguage language)
     : this(language, false)
 {
 }
Example #29
0
 private CrossApplyRewriter(QueryLanguage language)
 {
     this.language = language;
 }