RavenDB:如何检索嵌套集合中的顶级节点?
RavenDB: how to retrieve the top nodes in a nested collection?
我在 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; }
}
如何从数据库中检索名称和地址分别设置为 "aloma" 和“123”的城市的所有大洲?
您可以使用以下查询来做到这一点:
var 大陆 = session.Query()
.Where(c=>x.Countries.Any(国家=> country.Provinces.Any(p=>p.Cities.Any(城市=> city.Name == "123" && city.Address = = "aloma"))).ToList();
我在 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; }
}
如何从数据库中检索名称和地址分别设置为 "aloma" 和“123”的城市的所有大洲?
您可以使用以下查询来做到这一点:
var 大陆 = session.Query() .Where(c=>x.Countries.Any(国家=> country.Provinces.Any(p=>p.Cities.Any(城市=> city.Name == "123" && city.Address = = "aloma"))).ToList();