鉴于以下C#代码,我正在尝试检索所有拥有城市包括的省份的大陆:
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; }
}
我曾尝试使用下面的查询,但它似乎不起作用。你能帮我吗?
Expression<Func<Province, bool>> matchCities = rec =>
(rec.Cities.Count(fi => fi.Name == "Aloma" && fi.Address== "123") > 0)
&& (rec.Cities.Count(fj => fj.Name == "Hemane" && fj.Address== "435") > 0);
Func<Province, bool> funcMatchCities= matchCities.Compile();
var results3 = session.Query<Continent>()
.Where(top => top.Countries.Any(ta => ta.Province.Any(
rec => funcMatchCities(rec))))
.OfType<Continent>()
.ToList();