Пример #1
0
        private static IEnumerator <StreamResult <T> > YieldQuery <T>(IDocumentQuery <T> query, IEnumerator <RavenJObject> enumerator)
        {
            using (enumerator)
            {
                var queryOperation = ((DocumentQuery <T>)query).InitializeQueryOperation();
                queryOperation.DisableEntitiesTracking = true;

                while (enumerator.MoveNext())
                {
                    var result = enumerator.Current;
                    var meta   = result.Value <RavenJObject>(Constants.Metadata.Key);
                    query.InvokeAfterStreamExecuted(ref result);
                    string key  = null;
                    long?  etag = null;
                    if (meta != null)
                    {
                        key = meta.Value <string>("@id") ??
                              meta.Value <string>(Constants.Indexing.Fields.DocumentIdFieldName) ??
                              result.Value <string>(Constants.Indexing.Fields.DocumentIdFieldName);

                        var value = meta.Value <string>("@etag");
                        if (value != null)
                        {
                            etag = long.Parse(value);
                        }
                    }

                    var hasTransformer = queryOperation.IndexQuery.Transformer != null;
                    if (hasTransformer)
                    {
                        var values = result.Value <RavenJArray>("$values").ToArray();
                        foreach (RavenJObject value in values)
                        {
                            yield return(new StreamResult <T>
                            {
                                Document = queryOperation.Deserialize <T>(value),
                                Etag = etag,
                                Key = key,
                                Metadata = meta
                            });
                        }
                    }
                    else
                    {
                        yield return(new StreamResult <T>
                        {
                            Document = queryOperation.Deserialize <T>(result),
                            Etag = etag,
                            Key = key,
                            Metadata = meta
                        });
                    }
                }
            }
        }
Пример #2
0
        private IEnumerator <StreamResult <T> > YieldResults <T>(IDocumentQuery <T> query, IEnumerator <BlittableJsonReaderObject> enumerator)
        {
            var fieldsToFetch = ((DocumentQuery <T>)query).FieldsToFetchToken;

            while (enumerator.MoveNext())
            {
                var json = enumerator.Current;
                query.InvokeAfterStreamExecuted(json);

                yield return(CreateStreamResult <T>(json, fieldsToFetch));
            }
        }
Пример #3
0
        private IEnumerator <TimeSeriesStreamResult <T> > YieldTimeSeriesResults <T>(IDocumentQuery <T> query, StreamOperation.YieldStreamResults enumerator) where T : ITimeSeriesQueryStreamResult, new()
        {
            using (enumerator)
            {
                while (enumerator.MoveNext())
                {
                    using (var json = enumerator.Current)
                    {
                        query.InvokeAfterStreamExecuted(json);

                        yield return(CreateTimeSeriesStreamResult <T>(enumerator));
                    }
                }
            }
        }
Пример #4
0
        private IEnumerator <StreamResult <T> > YieldResults <T>(IDocumentQuery <T> query, IEnumerator <BlittableJsonReaderObject> enumerator)
        {
            using (enumerator)
            {
                var documentQuery = ((DocumentQuery <T>)query);
                var fieldsToFetch = documentQuery.FieldsToFetchToken;
                var isProjectInto = documentQuery.IsProjectInto;

                while (enumerator.MoveNext())
                {
                    using (var json = enumerator.Current)
                    {
                        query.InvokeAfterStreamExecuted(json);

                        yield return(CreateStreamResult <T>(json, fieldsToFetch, isProjectInto));
                    }
                }
            }
        }
Пример #5
0
        private static IEnumerator <StreamResult <T> > YieldQuery <T>(IDocumentQuery <T> query, IEnumerator <RavenJObject> enumerator)
        {
            using (enumerator)
            {
                var queryOperation = ((DocumentQuery <T>)query).InitializeQueryOperation();
                queryOperation.DisableEntitiesTracking = true;

                while (enumerator.MoveNext())
                {
                    var ravenJObject = enumerator.Current;
                    var meta         = ravenJObject.Value <RavenJObject>(Constants.Metadata);
                    query.InvokeAfterStreamExecuted(ref ravenJObject);
                    string key  = null;
                    Etag   etag = null;
                    if (meta != null)
                    {
                        key = meta.Value <string>("@id") ??
                              meta.Value <string>(Constants.DocumentIdFieldName) ??
                              ravenJObject.Value <string>(Constants.DocumentIdFieldName);

                        var value = meta.Value <string>("@etag");
                        if (value != null)
                        {
                            etag = Etag.Parse(value);
                        }
                    }

                    yield return(new StreamResult <T>
                    {
                        Document = queryOperation.Deserialize <T>(ravenJObject),
                        Etag = etag,
                        Key = key,
                        Metadata = meta
                    });
                }
            }
        }