2014-03-01 86 views
0

我想要如果列表的子類包含匹配。我是NHibernate的新手,正在尋求幫助。QueryOver標準與包含

謝謝

public class Shop 
{ 
    public virtual int ShopId { get; set; } 
    public virtual string ShopName { get; set; } 
    public virtual IList<DeliveryDistrict> DeliveryDistricts { get; set; } 
} 

public class DeliveryDistrict 
{ 
    public virtual int DeliveryDistrictId { get; set; } 
    public virtual Location.District District { get; set; } 
} 

public class District 
{ 
    public virtual int DistrictId { get; set; } 
    public virtual string DistrictName { get; set; } 
} 


stores = session.QueryOver<Entities.Shop.Shop>() 
.Where(f => f.DeliveryDistricts.Contains(District)).ToList(); 

stores = session.QueryOver<Entities.Shop.Shop>() 
.Where(p => p.DeliveryDistricts.Any(c => c.District.DistrictId == District.DistrictId)).List(); 

回答

0

我可以使它與查詢(LINQ)這樣的工作;

stores = session.Query<Entities.Shop.Shop>() 
.Where(p => p.DeliveryDistricts.Any(c => c.District.DistrictId == District.DistrictId)).ToList(); 

,但我想看看是否有人有QueryOver

爲例