コード例 #1
0
 public Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(long?fromEtag, int start = 0,
                                                                     int pageSize             = Int32.MaxValue, RavenPagingInformation pagingInformation = null, string transformer = null, Dictionary <string, object> transformerParameters = null, CancellationToken token = default(CancellationToken))
 {
     return(StreamAsync <T>(fromEtag: fromEtag, startsWith: null, matches: null, start: start, pageSize: pageSize, pagingInformation: pagingInformation, transformer: transformer, transformerParameters: transformerParameters, token: token));
 }
コード例 #2
0
 public T[] LoadStartingWith <T>(string keyPrefix, string matches = null, int start = 0, int pageSize = 25, string exclude = null, RavenPagingInformation pagingInformation = null, string skipAfter = null)
 {
     IncrementRequestCount();
     return(DatabaseCommands.StartsWith(keyPrefix, matches, start, pageSize, exclude: exclude, pagingInformation: pagingInformation, skipAfter: skipAfter)
            .Select(TrackEntity <T>)
            .ToArray());
 }
コード例 #3
0
 public IEnumerator <StreamResult <T> > Stream <T>(Etag fromEtag, int start = 0, int pageSize = Int32.MaxValue, RavenPagingInformation pagingInformation = null)
 {
     return(Stream <T>(fromEtag: fromEtag, startsWith: null, matches: null, start: start, pageSize: pageSize, pagingInformation: pagingInformation, skipAfter: null));
 }
コード例 #4
0
        public void PagingWithMatchesWithPagingInformation_Remote(string requestedStorage)
        {
            using (var documentStore = NewRemoteDocumentStore(requestedStorage: requestedStorage))
            {
                using (var session = documentStore.OpenSession())
                {
                    session.Store(new SomeEntity {
                        Id = "FooBar1"
                    });
                    session.Store(new SomeEntity {
                        Id = "BarFoo2"
                    });
                    session.Store(new SomeEntity {
                        Id = "FooBar3"
                    });
                    session.Store(new SomeEntity {
                        Id = "FooBar11"
                    });
                    session.Store(new SomeEntity {
                        Id = "FooBar12"
                    });
                    session.Store(new SomeEntity {
                        Id = "FooBar21"
                    });
                    session.Store(new SomeEntity {
                        Id = "FooBar5"
                    });
                    session.Store(new SomeEntity {
                        Id = "BarFoo7"
                    });
                    session.Store(new SomeEntity {
                        Id = "FooBar111"
                    });
                    session.Store(new SomeEntity {
                        Id = "BarFoo6"
                    });
                    session.Store(new SomeEntity {
                        Id = "FooBar6"
                    });
                    session.Store(new SomeEntity {
                        Id = "FooBar8"
                    });

                    session.SaveChanges();
                }

                var pagingInformation = new RavenPagingInformation();

                using (var session = documentStore.OpenSession())
                {
                    var fetchedDocuments = session.Advanced.Lazily
                                           .LoadStartingWith <SomeEntity>("FooBar", "1*", 0, 2, pagingInformation: pagingInformation)
                                           .Value
                                           .ToList();

                    Assert.Equal(0, pagingInformation.Start);
                    Assert.Equal(2, pagingInformation.PageSize);
                    Assert.Equal(2, pagingInformation.NextPageStart);

                    var foundDocKeys = fetchedDocuments.Select(doc => doc.Id).ToList();

                    Assert.Equal(2, foundDocKeys.Count);
                    Assert.Contains("FooBar1", foundDocKeys);
                    Assert.Contains("FooBar11", foundDocKeys);
                }

                using (var session = documentStore.OpenSession())
                {
                    var fetchedDocuments = session.Advanced.Lazily
                                           .LoadStartingWith <SomeEntity>("FooBar", "1*", 2, 1, pagingInformation: pagingInformation)
                                           .Value
                                           .ToList();

                    Assert.Equal(2, pagingInformation.Start);
                    Assert.Equal(1, pagingInformation.PageSize);
                    Assert.Equal(3, pagingInformation.NextPageStart);

                    var foundDocKeys = fetchedDocuments.Select(doc => doc.Id).ToList();

                    Assert.Equal(1, foundDocKeys.Count);
                    Assert.Contains("FooBar111", foundDocKeys);
                }

                using (var session = documentStore.OpenSession())
                {
                    var fetchedDocuments = session.Advanced.Lazily
                                           .LoadStartingWith <SomeEntity>("FooBar", "1*", 3, 10, pagingInformation: pagingInformation)
                                           .Value
                                           .ToList();

                    Assert.Equal(3, pagingInformation.Start);
                    Assert.Equal(10, pagingInformation.PageSize);
                    Assert.Equal(3, pagingInformation.NextPageStart);

                    var foundDocKeys = fetchedDocuments.Select(doc => doc.Id).ToList();

                    Assert.Equal(1, foundDocKeys.Count);
                    Assert.Contains("FooBar12", foundDocKeys);
                }
            }
        }
コード例 #5
0
        public T[] LoadStartingWith <T>(string keyPrefix, string matches = null, int start = 0, int pageSize = 25, string exclude = null, RavenPagingInformation pagingInformation = null)
        {
            IncrementRequestCount();
            var shards = GetCommandsToOperateOn(new ShardRequestData
            {
                EntityType = typeof(T),
                Keys       = { keyPrefix }
            });
            var results = shardStrategy.ShardAccessStrategy.Apply(shards, new ShardRequestData
            {
                EntityType = typeof(T),
                Keys       = { keyPrefix }
            }, (dbCmd, i) => dbCmd.StartsWith(keyPrefix, matches, start, pageSize, exclude: exclude));

            return(results.SelectMany(x => x).Select(TrackEntity <T>)
                   .ToArray());
        }
コード例 #6
0
 public LazyStartsWithOperation(string keyPrefix, string matches, string exclude, int start, int pageSize, InMemoryDocumentSessionOperations sessionOperations, RavenPagingInformation pagingInformation, string skipAfter)
 {
     this.keyPrefix         = keyPrefix;
     this.matches           = matches;
     this.exclude           = exclude;
     this.start             = start;
     this.pageSize          = pageSize;
     this.sessionOperations = sessionOperations;
     this.pagingInformation = pagingInformation;
     this.skipAfter         = skipAfter;
 }
コード例 #7
0
        public Task <IEnumerable <TResult> > LoadStartingWithAsync <TTransformer, TResult>(string keyPrefix, string matches = null, int start = 0, int pageSize = 25,
                                                                                           string exclude = null, RavenPagingInformation pagingInformation = null,
                                                                                           Action <ILoadConfiguration> configure = null) where TTransformer : AbstractTransformerCreationTask, new()
        {
            var transformer = new TTransformer().TransformerName;

            var configuration = new RavenLoadConfiguration();

            if (configure != null)
            {
                configure(configuration);
            }

            IncrementRequestCount();
            var shards = GetCommandsToOperateOn(new ShardRequestData
            {
                EntityType = typeof(TResult),
                Keys       = { keyPrefix }
            });

            return(shardStrategy.ShardAccessStrategy.ApplyAsync(shards, new ShardRequestData
            {
                EntityType = typeof(TResult),
                Keys = { keyPrefix }
            }, (dbCmd, i) => dbCmd.StartsWithAsync(keyPrefix, matches, start, pageSize, exclude: exclude, transformer: transformer,
                                                   queryInputs: configuration.QueryInputs))
                   .ContinueWith(task => (IEnumerable <TResult>)task.Result.SelectMany(x => x).Select(TrackEntity <TResult>).ToList()));
        }
コード例 #8
0
        private IEnumerator <StreamResult <T> > Stream <T>(Etag fromEtag, string startsWith, string matches, int start, int pageSize, RavenPagingInformation pagingInformation, string skipAfter)
        {
            IncrementRequestCount();
            using (var enumerator = DatabaseCommands.StreamDocs(fromEtag, startsWith, matches, start, pageSize, null, pagingInformation, skipAfter))
            {
                while (enumerator.MoveNext())
                {
                    var document = SerializationHelper.RavenJObjectToJsonDocument(enumerator.Current);

                    yield return(new StreamResult <T>
                    {
                        Document = (T)ConvertToEntity(typeof(T), document.Key, document.DataAsJson, document.Metadata),
                        Etag = document.Etag,
                        Key = document.Key,
                        Metadata = document.Metadata
                    });
                }
            }
        }
コード例 #9
0
        public void PagingWithoutFiltersWithPagingInformationAsync(string requestedStorage)
        {
            using (var documentStore = NewRemoteDocumentStore(requestedStorage: requestedStorage))
            {
                documentStore.DatabaseCommands.Put("FooBar1", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo2", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar3", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar11", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar12", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar21", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar5", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo7", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar111", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo6", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar6", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar8", null, new RavenJObject(), new RavenJObject());

                var pagingInformation = new RavenPagingInformation();
                var fetchedDocuments  = documentStore
                                        .AsyncDatabaseCommands
                                        .StartsWithAsync("FooBar", string.Empty, 0, 4, pagingInformation: pagingInformation, exclude: string.Empty)
                                        .Result
                                        .ToList();

                var foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                                   .ToList();

                Assert.Equal(4, foundDocKeys.Count);
                Assert.Contains("FooBar1", foundDocKeys);
                Assert.Contains("FooBar11", foundDocKeys);
                Assert.Contains("FooBar111", foundDocKeys);
                Assert.Contains("FooBar12", foundDocKeys);

                fetchedDocuments = documentStore
                                   .AsyncDatabaseCommands
                                   .StartsWithAsync("FooBar", string.Empty, 4, 4, pagingInformation: pagingInformation, exclude: string.Empty)
                                   .Result
                                   .ToList();

                foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                               .ToList();

                Assert.Equal(4, foundDocKeys.Count);
                Assert.Contains("FooBar21", foundDocKeys);
                Assert.Contains("FooBar3", foundDocKeys);
                Assert.Contains("FooBar5", foundDocKeys);
                Assert.Contains("FooBar6", foundDocKeys);

                fetchedDocuments = documentStore
                                   .AsyncDatabaseCommands
                                   .StartsWithAsync("FooBar", string.Empty, 8, 4, pagingInformation: pagingInformation, exclude: string.Empty)
                                   .Result
                                   .ToList();

                foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                               .ToList();

                Assert.Equal(1, foundDocKeys.Count);
                Assert.Contains("FooBar8", foundDocKeys);
            }
        }
コード例 #10
0
 public Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(string startsWith, string matches = null, int start = 0, int pageSize = Int32.MaxValue, RavenPagingInformation pagingInformation = null, string skipAfter = null, string transformer = null, Dictionary <string, RavenJToken> transformerParameters = null, CancellationToken token = default(CancellationToken))
 {
     throw new NotSupportedException("Streams are currently not supported by sharded document store");
 }
コード例 #11
0
ファイル: ServerClient.cs プロジェクト: marysam26/ravendb
 public IEnumerator <RavenJObject> StreamDocs(Etag fromEtag = null, string startsWith = null, string matches = null, int start = 0, int pageSize = int.MaxValue, string exclude = null, RavenPagingInformation pagingInformation = null, string skipAfter = null)
 {
     return(new AsyncEnumerableWrapper <RavenJObject>(
                asyncServerClient.StreamDocsAsync(fromEtag, startsWith, matches, start, pageSize, exclude, pagingInformation, skipAfter).Result));
 }
コード例 #12
0
 Lazy <Task <TResult[]> > IAsyncLazySessionOperations.LoadStartingWithAsync <TResult>(string keyPrefix, string matches, int start, int pageSize, string exclude, RavenPagingInformation pagingInformation, string skipAfter, CancellationToken token)
 {
     throw new NotImplementedException();
 }
コード例 #13
0
        public void PagingWithExcludesWithPagingInformation(string requestedStorage)
        {
            using (var documentStore = NewDocumentStore(requestedStorage: requestedStorage))
            {
                documentStore.SystemDatabase.Documents.Put("FooBar1", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("BarFoo2", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("FooBar3", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("FooBar11", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("FooBar12", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("FooBar21", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("FooBar5", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("BarFoo7", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("FooBar111", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("BarFoo6", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("FooBar6", null, new RavenJObject(), new RavenJObject(), null);
                documentStore.SystemDatabase.Documents.Put("FooBar8", null, new RavenJObject(), new RavenJObject(), null);

                var pagingInformation = new RavenPagingInformation();
                var fetchedDocuments  = documentStore
                                        .DatabaseCommands
                                        .StartsWith("FooBar", string.Empty, 0, 2, pagingInformation: pagingInformation, exclude: "1*")
                                        .ToList();

                Assert.Equal(0, pagingInformation.Start);
                Assert.Equal(2, pagingInformation.PageSize);
                Assert.Equal(6, pagingInformation.NextPageStart);

                var foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                                   .ToList();

                Assert.Equal(2, foundDocKeys.Count);
                Assert.Contains("FooBar21", foundDocKeys);
                Assert.Contains("FooBar3", foundDocKeys);

                fetchedDocuments = documentStore
                                   .DatabaseCommands
                                   .StartsWith("FooBar", string.Empty, 2, 2, pagingInformation: pagingInformation, exclude: "1*")
                                   .ToList();

                Assert.Equal(2, pagingInformation.Start);
                Assert.Equal(2, pagingInformation.PageSize);
                Assert.Equal(8, pagingInformation.NextPageStart);

                foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                               .ToList();

                Assert.Equal(2, foundDocKeys.Count);
                Assert.Contains("FooBar5", foundDocKeys);
                Assert.Contains("FooBar6", foundDocKeys);

                fetchedDocuments = documentStore
                                   .DatabaseCommands
                                   .StartsWith("FooBar", string.Empty, 4, 2, pagingInformation: pagingInformation, exclude: "1*")
                                   .ToList();

                Assert.Equal(4, pagingInformation.Start);
                Assert.Equal(2, pagingInformation.PageSize);
                Assert.Equal(8, pagingInformation.NextPageStart);

                foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                               .ToList();

                Assert.Equal(1, foundDocKeys.Count);
                Assert.Contains("FooBar8", foundDocKeys);
            }
        }
コード例 #14
0
        private async Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(long?fromEtag, string startsWith, string matches,
                                                                                   int start, int pageSize, RavenPagingInformation pagingInformation = null, string skipAfter = null, string transformer = null,
                                                                                   Dictionary <string, object> transformerParameters = null, CancellationToken token          = default(CancellationToken))
        {
            var streamOperation = new StreamOperation(this);
            var command         = streamOperation.CreateRequest(fromEtag, startsWith, matches, start, pageSize, null, pagingInformation, skipAfter, transformer,
                                                                transformerParameters);
            await RequestExecuter.ExecuteAsync(command, Context, token).ConfigureAwait(false);

            var result = streamOperation.SetResultAsync(command.Result);

            return(new YieldStream <T>(this, result, token));
        }
コード例 #15
0
 public Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(string startsWith, string matches = null, int start = 0,
                                                                     int pageSize = Int32.MaxValue, RavenPagingInformation pagingInformation = null, string skipAfter = null, CancellationToken token = default(CancellationToken))
 {
     return(StreamAsync <T>(fromEtag: null, startsWith: startsWith, matches: matches, start: start, pageSize: pageSize, pagingInformation: pagingInformation, skipAfter: skipAfter, token: token));
 }
コード例 #16
0
        public void PagingWithMatchesWithPagingInformation(string requestedStorage)
        {
            using (var documentStore = NewRemoteDocumentStore(requestedStorage: requestedStorage))
            {
                documentStore.DatabaseCommands.Put("FooBar1", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo2", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar3", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar11", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar12", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar21", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar5", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo7", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar111", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo6", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar6", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar8", null, new RavenJObject(), new RavenJObject());

                var pagingInformation = new RavenPagingInformation();
                var fetchedDocuments  = documentStore
                                        .DatabaseCommands
                                        .StartsWith("FooBar", "1*", 0, 2, pagingInformation: pagingInformation)
                                        .ToList();

                Assert.Equal(0, pagingInformation.Start);
                Assert.Equal(2, pagingInformation.PageSize);
                Assert.Equal(2, pagingInformation.NextPageStart);

                var foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                                   .ToList();

                Assert.Equal(2, foundDocKeys.Count);
                Assert.Contains("FooBar1", foundDocKeys);
                Assert.Contains("FooBar11", foundDocKeys);

                fetchedDocuments = documentStore
                                   .DatabaseCommands
                                   .StartsWith("FooBar", "1*", 2, 1, pagingInformation: pagingInformation)
                                   .ToList();

                Assert.Equal(2, pagingInformation.Start);
                Assert.Equal(1, pagingInformation.PageSize);
                Assert.Equal(3, pagingInformation.NextPageStart);

                foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                               .ToList();

                Assert.Equal(1, foundDocKeys.Count);
                Assert.Contains("FooBar111", foundDocKeys);

                fetchedDocuments = documentStore
                                   .DatabaseCommands
                                   .StartsWith("FooBar", "1*", 3, 10, pagingInformation: pagingInformation)
                                   .ToList();

                Assert.Equal(3, pagingInformation.Start);
                Assert.Equal(10, pagingInformation.PageSize);
                Assert.Equal(3, pagingInformation.NextPageStart);

                foundDocKeys = fetchedDocuments.Select(doc => doc.Key)
                               .ToList();

                Assert.Equal(1, foundDocKeys.Count);
                Assert.Contains("FooBar12", foundDocKeys);
            }
        }
コード例 #17
0
        private async Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(Etag fromEtag, string startsWith, string matches, int start, int pageSize, RavenPagingInformation pagingInformation = null, string skipAfter = null, CancellationToken token = default(CancellationToken))
        {
            var enumerator = await AsyncDatabaseCommands.StreamDocsAsync(fromEtag, startsWith, matches, start, pageSize, pagingInformation : pagingInformation, skipAfter : skipAfter, token : token).ConfigureAwait(false);

            return(new DocsYieldStream <T>(this, enumerator, token));
        }
コード例 #18
0
        public void StreamingWithPagingInformationAsync(string requestedStorage)
        {
            using (var documentStore = NewRemoteDocumentStore(requestedStorage: requestedStorage))
            {
                documentStore.DatabaseCommands.Put("FooBar1", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo2", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar3", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar11", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar12", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar21", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar5", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo7", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar111", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("BarFoo6", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar6", null, new RavenJObject(), new RavenJObject());
                documentStore.DatabaseCommands.Put("FooBar8", null, new RavenJObject(), new RavenJObject());

                var pagingInformation = new RavenPagingInformation();
                var fetchedDocuments  = documentStore
                                        .AsyncDatabaseCommands
                                        .StreamDocsAsync(startsWith: "FooBar", matches: string.Empty, start: 0, pageSize: 4, exclude: string.Empty, pagingInformation: pagingInformation).Result;

                var foundDocKeys = new List <string>();

                while (fetchedDocuments.MoveNextAsync().Result)
                {
                    foundDocKeys.Add(fetchedDocuments.Current["@metadata"].Value <string>("@id"));
                }

                Assert.Equal(4, foundDocKeys.Count);
                Assert.Contains("FooBar1", foundDocKeys);
                Assert.Contains("FooBar11", foundDocKeys);
                Assert.Contains("FooBar111", foundDocKeys);
                Assert.Contains("FooBar12", foundDocKeys);

                fetchedDocuments = documentStore
                                   .AsyncDatabaseCommands
                                   .StreamDocsAsync(startsWith: "FooBar", matches: string.Empty, start: 4, pageSize: 4, exclude: string.Empty, pagingInformation: pagingInformation).Result;

                foundDocKeys = new List <string>();

                while (fetchedDocuments.MoveNextAsync().Result)
                {
                    foundDocKeys.Add(fetchedDocuments.Current["@metadata"].Value <string>("@id"));
                }

                Assert.Equal(4, foundDocKeys.Count);
                Assert.Contains("FooBar21", foundDocKeys);
                Assert.Contains("FooBar3", foundDocKeys);
                Assert.Contains("FooBar5", foundDocKeys);
                Assert.Contains("FooBar6", foundDocKeys);

                fetchedDocuments = documentStore
                                   .AsyncDatabaseCommands
                                   .StreamDocsAsync(startsWith: "FooBar", matches: string.Empty, start: 8, pageSize: 4, exclude: string.Empty, pagingInformation: pagingInformation).Result;

                foundDocKeys = new List <string>();

                while (fetchedDocuments.MoveNextAsync().Result)
                {
                    foundDocKeys.Add(fetchedDocuments.Current["@metadata"].Value <string>("@id"));
                }

                Assert.Equal(1, foundDocKeys.Count);
                Assert.Contains("FooBar8", foundDocKeys);
            }
        }
コード例 #19
0
        public Task <IEnumerable <T> > LoadStartingWithAsync <T>(string keyPrefix, string matches = null, int start = 0, int pageSize = 25, string exclude = null, RavenPagingInformation pagingInformation = null)
        {
            IncrementRequestCount();
            var shards = GetCommandsToOperateOn(new ShardRequestData
            {
                EntityType = typeof(T),
                Keys       = { keyPrefix }
            });

            return(shardStrategy.ShardAccessStrategy.ApplyAsync(shards, new ShardRequestData
            {
                EntityType = typeof(T),
                Keys = { keyPrefix }
            }, (dbCmd, i) => dbCmd.StartsWithAsync(keyPrefix, matches, start, pageSize, exclude: exclude))
                   .ContinueWith(task => (IEnumerable <T>)task.Result.SelectMany(x => x).Select(TrackEntity <T>).ToList()));
        }
コード例 #20
0
ファイル: ServerClient.cs プロジェクト: ravendb/silverlight
 /// <summary>
 /// Streams the documents by etag OR starts with the prefix and match the matches
 /// Will return *all* results, regardless of the number of itmes that might be returned.
 /// </summary>
 public IEnumerator <RavenJObject> StreamDocs(Etag fromEtag, string startsWith, string matches, int start, int pageSize,
                                              string exclude, RavenPagingInformation pagingInformation = null)
 {
     return(new AsycnEnumerableWrapper <RavenJObject>(
                asyncServerClient.StreamDocsAsync(fromEtag, startsWith, matches, start, pageSize, exclude, pagingInformation).Result));
 }
コード例 #21
0
 public Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(Etag fromEtag, int start = 0, int pageSize = Int32.MaxValue, RavenPagingInformation pagingInformation = null)
 {
     throw new NotSupportedException("Streams are currently not supported by sharded document store");
 }
コード例 #22
0
        Lazy <Task <T[]> > IAsyncLazySessionOperations.LoadStartingWithAsync <T>(string keyPrefix, string matches, int start, int pageSize, string exclude, RavenPagingInformation pagingInformation, string skipAfter, CancellationToken token = default(CancellationToken))
        {
            var operation = new LazyStartsWithOperation <T>(keyPrefix, matches, exclude, start, pageSize, this, pagingInformation, skipAfter);

            return(AddLazyOperation <T[]>(operation, null, token));
        }
コード例 #23
0
 public IEnumerator <StreamResult <T> > Stream <T>(string startsWith, string matches = null, int start = 0, int pageSize = Int32.MaxValue, RavenPagingInformation pagingInformation = null)
 {
     throw new NotSupportedException("Streams are currently not supported by sharded document store");
 }
コード例 #24
0
 /// <summary>
 /// Load documents with the specified key prefix
 /// </summary>
 public Task <IEnumerable <T> > LoadStartingWithAsync <T>(string keyPrefix, string matches = null, int start = 0, int pageSize = 25, string exclude = null, RavenPagingInformation pagingInformation = null, string skipAfter = null, CancellationToken token = default(CancellationToken))
 {
     return(AsyncDatabaseCommands.StartsWithAsync(keyPrefix, matches, start, pageSize, exclude: exclude, pagingInformation: pagingInformation, skipAfter: skipAfter, token: token)
            .ContinueWith(task => (IEnumerable <T>)task.Result.Select(TrackEntity <T>).ToList(), token));
 }
コード例 #25
0
        Lazy <T[]> ILazySessionOperations.LoadStartingWith <T>(string keyPrefix, string matches, int start, int pageSize, string exclude, RavenPagingInformation pagingInformation)
        {
            IncrementRequestCount();
            var cmds = GetCommandsToOperateOn(new ShardRequestData
            {
                EntityType = typeof(T),
                Keys       = { keyPrefix }
            });

            var lazyLoadOperation = new LazyStartsWithOperation <T>(keyPrefix, matches, exclude, start, pageSize, this, null);

            return(AddLazyOperation <T[]>(lazyLoadOperation, null, cmds));
        }
コード例 #26
0
        public Task <IEnumerable <TResult> > LoadStartingWithAsync <TTransformer, TResult>(string keyPrefix, string matches = null, int start = 0, int pageSize = 25,
                                                                                           string exclude = null, RavenPagingInformation pagingInformation = null,
                                                                                           Action <ILoadConfiguration> configure = null,
                                                                                           string skipAfter = null, CancellationToken token = default(CancellationToken)) where TTransformer : AbstractTransformerCreationTask, new()
        {
            var transformer = new TTransformer().TransformerName;

            var configuration = new RavenLoadConfiguration();

            if (configure != null)
            {
                configure(configuration);
            }

            return(AsyncDatabaseCommands.StartsWithAsync(keyPrefix, matches, start, pageSize, exclude: exclude,
                                                         pagingInformation: pagingInformation, transformer: transformer,
                                                         transformerParameters: configuration.TransformerParameters,
                                                         skipAfter: skipAfter, token: token)
                   .ContinueWith(
                       task => (IEnumerable <TResult>)task.Result.Select(TrackEntity <TResult>).ToList(), token));
        }
コード例 #27
0
        Lazy <T[]> ILazySessionOperations.LoadStartingWith <T>(string keyPrefix, string matches, int start, int pageSize, string exclude, RavenPagingInformation pagingInformation, string skipAfter)
        {
            var operation = new LazyStartsWithOperation <T>(keyPrefix, matches, exclude, start, pageSize, this, pagingInformation, skipAfter);

            return(AddLazyOperation <T[]>(operation, null));
        }
コード例 #28
0
 public Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(Etag fromEtag, int start = 0,
                                                                     int pageSize             = Int32.MaxValue, RavenPagingInformation pagingInformation = null, CancellationToken token = default(CancellationToken))
 {
     return(StreamAsync <T>(fromEtag: fromEtag, startsWith: null, matches: null, start: start, pageSize: pageSize, pagingInformation: pagingInformation, token: token));
 }
コード例 #29
0
 public IEnumerator <StreamResult <T> > Stream <T>(string startsWith, string matches = null, int start = 0, int pageSize = Int32.MaxValue, RavenPagingInformation pagingInformation = null, string skipAfter = null)
 {
     return(Stream <T>(fromEtag: null, startsWith: startsWith, matches: matches, start: start, pageSize: pageSize, pagingInformation: pagingInformation, skipAfter: skipAfter));
 }
コード例 #30
0
        public IEnumerator <RavenJObject> StreamDocs(Etag fromEtag = null, string startsWith = null, string matches = null, int start = 0, int pageSize = int.MaxValue, string exclude = null, RavenPagingInformation pagingInformation = null, string skipAfter = null, string transformer = null, Dictionary <string, RavenJToken> transformerParameters = null)
        {
            var streamDocsAsync = AsyncHelpers.RunSync(() => asyncServerClient.StreamDocsAsync(fromEtag, startsWith, matches, start, pageSize, exclude, pagingInformation, skipAfter, transformer, transformerParameters));

            return(new AsyncEnumerableWrapper <RavenJObject>(streamDocsAsync));
        }