我将以下类的对象存储在ravendb数据库中:
public class Continent
{
public string Name { get; set; }
public List<Country> Countries{ get; set; }
}
public class Countries
{
public string Name { get; set; }
public List<Province> Provinces{ get; set; }
}
public class Province
{
public string Name { get; set; }
public List<Province> Cities { get; set; }
}
public class City
{
public string Name { get; set; }
public string Address { get; set; }
}
感谢帖子(RavenDB: how to retrieve the top nodes in a nested collection?)我学会了如何使用session.Query从数据库中检索所有具有Name和Address的城市分别设置为“aloma”和“123”的大陆。我想使用session.Advanced.DocumentQuery编写相同的查询。那么请告诉我如何将以下查询转换为session.Advanced.DocumentQuery:
var continents = session.Query<Continent>()
.Where(x => x.Countries.Any(country =>
country.Provinces.Any(p =>
p.Cities.Any(city =>
city.Name == "123" && city.Address == "aloma")))
.OfType<Continent>()
.ToList();