Exemplo n.º 1
0
        public void Can_chain_wheres_when_querying_collection_with_any()
        {
            var entity = new EntityWithTags()
            {
                Id   = Guid.NewGuid(),
                Tags = new [] { "FOO", "BAR" }
            };

            using (var documentStore = NewDocumentStore())
            {
                using (var session = documentStore.OpenSession())
                {
                    session.Store(entity);
                    session.SaveChanges();
                }

                using (var session = documentStore.OpenSession())
                {
                    IQueryable <EntityWithTags> query = session.Query <EntityWithTags>()
                                                        .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite());

                    foreach (var tag in new string[] { "FOO", "BAR" })
                    {
                        string localTag = tag;
                        query = query.Where(e => e.Tags.Any(t => t == localTag));
                    }

                    Assert.NotEmpty(query.ToList());
                }
            }
        }
Exemplo n.º 2
0
        public void Can_chain_wheres_when_querying_collection_with_any()
        {
            var entity = new EntityWithTags()
            {
                Id = Guid.NewGuid(),
                Tags = new [] { "FOO", "BAR" }
            };
            using(var documentStore = NewDocumentStore())
            {
                using (var session = documentStore.OpenSession())
                {
                    session.Store(entity);
                    session.SaveChanges();
                }

                using (var session = documentStore.OpenSession())
                {
                    IQueryable<EntityWithTags> query = session.Query<EntityWithTags>()
                        .Customize(x=>x.WaitForNonStaleResultsAsOfLastWrite());

                    foreach (var tag in new string[] { "FOO", "BAR" })
                    {
                        string localTag = tag;
                        query = query.Where(e => e.Tags.Any(t => t == localTag));
                    }

                    Assert.NotEmpty(query.ToList());
                }
            }
        }