RavenDB:如何检索嵌套集合中的顶级节点? [英] RavenDB: how to retrieve the top nodes in a nested collection?
本文介绍了RavenDB:如何检索嵌套集合中的顶级节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将以下类的对象存储在ravendb数据库中:
I stored the objects of the following classes in a ravendb database:
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?
How can I retrieve from the database all the continents having cities with Name and Address respectively set to "aloma" and "123"?
推荐答案
您可以使用以下查询:
var continents = session.Query()
.Where(c => x.Countries.Any(country => country.Provinces.Any(p => p.Cities .Any(city => city.Name ==123&&& city.Address ==aloma))。ToList();
var continents = session.Query() .Where(c=>x.Countries.Any(country => country.Provinces.Any(p=>p.Cities.Any(city => city.Name == "123" && city.Address == "aloma"))).ToList();
这篇关于RavenDB:如何检索嵌套集合中的顶级节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文