public void query_against_number_array() { var doc1 = new DocWithArrays { Numbers = new [] { 1, 2, 3 } }; var doc2 = new DocWithArrays { Numbers = new [] { 3, 4, 5 } }; var doc3 = new DocWithArrays { Numbers = new [] { 5, 6, 7 } }; theSession.Store(doc1, doc2, doc3); theSession.SaveChanges(); theSession.Query <DocWithArrays>().Where(x => x.Numbers.Contains(3)).ToArray() .Select(x => x.Id).ShouldHaveTheSameElementsAs(doc1.Id, doc2.Id); }
public void query_against_date_array() { var doc1 = new DocWithArrays { Dates = new[] { DateTime.Today, DateTime.Today.AddDays(1), DateTime.Today.AddDays(2) } }; var doc2 = new DocWithArrays { Dates = new[] { DateTime.Today.AddDays(2), DateTime.Today.AddDays(3), DateTime.Today.AddDays(4) } }; var doc3 = new DocWithArrays { Dates = new[] { DateTime.Today.AddDays(4), DateTime.Today.AddDays(5), DateTime.Today.AddDays(6) } }; theSession.Store(doc1); theSession.Store(doc2); theSession.Store(doc3); theSession.SaveChanges(); theSession.Query <DocWithArrays>().Where(x => x.Dates.Contains(DateTime.Today.AddDays(2))).ToArray() .Select(x => x.Id).ShouldHaveTheSameElementsAs(doc1.Id, doc2.Id); }
public void query_against_string_array_with_Count_method() { var doc1 = new DocWithArrays { Strings = new [] { "a", "b", "c" } }; var doc2 = new DocWithArrays { Strings = new [] { "c", "d", "e" } }; var doc3 = new DocWithArrays { Strings = new [] { "d", "e", "f", "g" } }; theSession.Store(doc1); theSession.Store(doc2); theSession.Store(doc3); theSession.SaveChanges(); theSession.Query <DocWithArrays>().Where(x => x.Strings.Count() == 4).ToArray() .Select(x => x.Id).ShouldHaveTheSameElementsAs(doc3.Id); }
public void query_against_string_array_with_Any() { var doc1 = new DocWithArrays { Strings = new [] { "a", "b", "c" } }; var doc2 = new DocWithArrays { Strings = new [] { "c", "d", "e" } }; var doc3 = new DocWithArrays { Strings = new [] { "d", "e", "f" } }; theSession.Store(doc1); theSession.Store(doc2); theSession.Store(doc3); theSession.SaveChanges(); theSession.Query <DocWithArrays>().Where(x => x.Strings.Any(_ => _ == "c")).ToArray() .Select(x => x.Id).ShouldHaveTheSameElementsAs(doc1.Id, doc2.Id); }