public void query_against_number_list_with_any() { var doc1 = new DocWithLists { Numbers = new List <int> { 1, 2, 3 } }; var doc2 = new DocWithLists { Numbers = new List <int> { 3, 4, 5 } }; var doc3 = new DocWithLists { Numbers = new List <int> { 5, 6, 7 } }; var doc4 = new DocWithLists { Numbers = new List <int> { } }; theSession.Store(doc1, doc2, doc3, doc4); theSession.SaveChanges(); theSession.Query <DocWithLists>().Where(x => x.Numbers.Any(_ => _ == 3)).ToArray() .Select(x => x.Id).ShouldHaveTheSameElementsAs(doc1.Id, doc2.Id); // Or without any predicate theSession.Query <DocWithLists>() .Count(x => x.Numbers.Any()).ShouldBe(3); }
public void query_against_number_list_with_count_property_and_other_operators() { var doc1 = new DocWithLists { Numbers = new List <int> { 1, 2, 3 } }; var doc2 = new DocWithLists { Numbers = new List <int> { 3, 4, 5 } }; var doc3 = new DocWithLists { Numbers = new List <int> { 5, 6, 7, 8 } }; theSession.Store(doc1); theSession.Store(doc2); theSession.Store(doc3); theSession.SaveChanges(); theSession.Query <DocWithLists>() .Single(x => x.Numbers.Count > 3).Id.ShouldBe(doc3.Id); }
public void query_against_number_list() { var doc1 = new DocWithLists { Numbers = new List <int> { 1, 2, 3 } }; var doc2 = new DocWithLists { Numbers = new List <int> { 3, 4, 5 } }; var doc3 = new DocWithLists { Numbers = new List <int> { 5, 6, 7 } }; theSession.Store(doc1); theSession.Store(doc2); theSession.Store(doc3); theSession.SaveChanges(); theSession.Query <DocWithLists>().Where(x => x.Numbers.Contains(3)).ToArray() .Select(x => x.Id).ShouldHaveTheSameElementsAs(doc1.Id, doc2.Id); }