Beispiel #1
0
        public LinqQuery(DocumentStore store, QueryModel model, IIncludeJoin[] joins, QueryStatistics stats)
        {
            Model  = model;
            _store = store;
            _joins = joins;

            // TODO -- going to have to push in the ITenant eventually
            _mapping = store.Tenancy.Default.MappingFor(model.SourceType()).ToQueryableDocument();

            for (var i = 0; i < model.BodyClauses.Count; i++)
            {
                var clause = model.BodyClauses[i];
                if (clause is AdditionalFromClause)
                {
                    // TODO -- to be able to go recursive, have _subQuery start to read the BodyClauses
                    _subQuery = new SelectManyQuery(store, _mapping, model, i + 1);

                    break;
                }
            }

            Selector   = BuildSelector(joins, stats, _subQuery, joins);
            SourceType = Model.SourceType();

            Where = buildWhereFragment();
        }
Beispiel #2
0
        public LinqQuery(IDocumentSchema schema, QueryModel model, IIncludeJoin[] joins, QueryStatistics stats)
        {
            Model    = model;
            _schema  = schema;
            _joins   = joins;
            _mapping = schema.MappingFor(model.SourceType()).ToQueryableDocument();

            for (var i = 0; i < model.BodyClauses.Count; i++)
            {
                var clause = model.BodyClauses[i];
                if (clause is AdditionalFromClause)
                {
                    // TODO -- to be able to go recursive, have _subQuery start to read the BodyClauses
                    _subQuery = new SelectManyQuery(schema, _mapping, model, i + 1);


                    break;
                }
            }

            Selector   = BuildSelector(joins, stats, _subQuery, joins);
            SourceType = Model.SourceType();

            Where = buildWhereFragment();
        }
Beispiel #3
0
        // Leave this code here, because it will need to use the SubQuery logic in its selection
        public ISelector <T> BuildSelector(IIncludeJoin[] joins, QueryStatistics stats, SelectManyQuery subQuery,
                                           IIncludeJoin[] includeJoins)
        {
            var selector =
                _innerSelector = SelectorParser.ChooseSelector <T>("d.data", _store.Tenancy.Default, _mapping, Model, subQuery, _store.Serializer, joins);

            if (stats != null)
            {
                selector = new StatsSelector <T>(selector);
            }

            if (joins.Any())
            {
                selector = new IncludeSelector <T>(_store.Storage, selector, joins);
            }

            return(selector);
        }