Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# RavenDB:如何检索嵌套集合中的顶部节点?_C#_Collections_Nested_Ravendb - Fatal编程技术网

C# RavenDB:如何检索嵌套集合中的顶部节点?

C# RavenDB:如何检索嵌套集合中的顶部节点?,c#,collections,nested,ravendb,C#,Collections,Nested,Ravendb,我将以下类的对象存储在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&l

我将以下类的对象存储在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; }
    }
公共类
{
公共字符串名称{get;set;}
公共列表国家{get;set;}
}
公营国家
{
公共字符串名称{get;set;}
公共列表省份{get;set;}
}
公营省
{
公共字符串名称{get;set;}
公共列表城市{get;set;}
}
公营城市
{
公共字符串名称{get;set;}
公共字符串地址{get;set;}
}

如何从数据库中检索名称和地址分别设置为“aloma”和“123”的所有大陆城市?

您可以使用以下查询进行检索:

var columents=session.Query()
.Where(c=>x.Countries.Any(country=>country.yevens.Any(p=>p.Cities.Any(city=>city.Name==“123”&&city.Address==“aloma”)).ToList();

感谢您的快速回复。这对我帮助很大。我对它进行了一些修改,以便在我的环境中使用它,并导致了一个类似于以下的查询:var contricons=session.query()(x=>x.Countries.Any(country=>country.yevens.Any(p=>p.Cities.Any(city=>city.Name==“123”&&city.Address==“aloma”)))).OfType().ToList();我还有一个与前一个问题相关的问题。我试图检索所有大陆上有省份的城市,包括:1)名称和地址分别设置为“aloma”和“123”的城市和2)另一个城市,名称和地址分别设置为“Hemane”和“435”。我尝试了不同的方法,但迄今为止没有成功。你能帮助我吗?提前谢谢。你需要两个Any()条款来描述这两个城市。