示例#1
0
        public void can_get_the_total_from_a_compiled_query()
        {
            var count = theSession.Query <Target>().Count(x => x.Number > 10);

            count.ShouldBeGreaterThan(0);

            var query = new TargetPaginationQuery(2, 5);
            var list  = theSession
                        .Query(query)
                        .ToList();

            list.Any().ShouldBeTrue();

            query.Stats.TotalResults.ShouldBe(count);
        }
        public async Task can_use_json_streaming_with_statistics()
        {
            var count = theSession.Query <Target>().Count(x => x.Number > 10);

            count.ShouldBeGreaterThan(0);

            var query       = new TargetPaginationQuery(2, 5);
            var stream      = new MemoryStream();
            var resultCount = await theSession
                              .StreamJsonMany(query, stream);

            resultCount.ShouldBeGreaterThan(0);

            stream.Position = 0;
            var list = theStore.Options.Serializer().FromJson <Target[]>(stream);

            list.Length.ShouldBe(5);
        }
        public void can_get_the_total_from_a_compiled_query_running_in_a_batch_sync()
        {
            var count = theSession.Query <Target>().Count(x => x.Number > 10);

            SpecificationExtensions.ShouldBeGreaterThan(count, 0);

            var query = new TargetPaginationQuery(2, 5);

            var batch = theSession.CreateBatchQuery();

            var targets = batch.Query(query);

            batch.ExecuteSynchronously();

            targets.Result
            .Any().ShouldBeTrue();

            query.Stats.TotalResults.ShouldBe(count);
        }
        public async Task can_get_the_total_from_a_compiled_query_running_in_a_batch()
        {
            var count = await theSession.Query <Target>().Where(x => x.Number > 10).CountAsync().ConfigureAwait(false);

            SpecificationExtensions.ShouldBeGreaterThan(count, 0);

            var query = new TargetPaginationQuery(2, 5);

            var batch = theSession.CreateBatchQuery();

            var targets = batch.Query(query);

            await batch.Execute().ConfigureAwait(false);

            (await targets.ConfigureAwait(false))
            .Any().ShouldBeTrue();

            query.Stats.TotalResults.ShouldBe(count);
        }