Exemplo n.º 1
0
        public async Task select_many_against_integer_array_async()
        {
            var product1 = new ProductWithNumbers {
                Tags = new[] { 1, 2, 3 }
            };
            var product2 = new ProductWithNumbers {
                Tags = new[] { 2, 3, 4 }
            };
            var product3 = new ProductWithNumbers {
                Tags = new[] { 3, 4, 5 }
            };

            using (var session = theStore.OpenSession())
            {
                session.Store(product1, product2, product3);
                await session.SaveChangesAsync();
            }


            using (var query = theStore.QuerySession())
            {
                var distinct = await query.Query <ProductWithNumbers>().SelectMany(x => x.Tags).Distinct().ToListAsync();

                distinct.OrderBy(x => x).ShouldHaveTheSameElementsAs(1, 2, 3, 4, 5);

                var names = query.Query <ProductWithNumbers>().SelectMany(x => x.Tags).ToList();
                names
                .Count().ShouldBe(9);
            }
        }
Exemplo n.º 2
0
        public async Task select_many_against_integer_array_async()
        {
            var product1 = new ProductWithNumbers {Tags = new[] {1, 2, 3}};
            var product2 = new ProductWithNumbers {Tags = new[] {2, 3, 4}};
            var product3 = new ProductWithNumbers {Tags = new[] {3, 4, 5}};

            using (var session = theStore.OpenSession())
            {
                session.Store(product1, product2, product3);
                await session.SaveChangesAsync();
            }


            using (var query = theStore.QuerySession())
            {
                var distinct = await query.Query<ProductWithNumbers>().SelectMany(x => x.Tags).Distinct().ToListAsync();

                distinct.OrderBy(x => x).ShouldHaveTheSameElementsAs(1, 2, 3, 4, 5);

                var names = query.Query<ProductWithNumbers>().SelectMany(x => x.Tags).ToList();
                names
                    .Count().ShouldBe(9);
            }
        }