我将以下类的对象存储在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”的大陆?
答案 0 :(得分:0)
您可以使用以下查询执行此操作:
var continents = session.Query() .Where(c =&gt; x.Countries.Any(country =&gt; country.Provinces.Any(p =&gt; p.Cities.Any(city =&gt; city.Name ==“123”&amp;&amp; city .Address ==“aloma”)))。ToList();