Question

I am trying to get if list of subclass contains a match. I am new at NHibernate and looking for help.

thank you

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();
Was it helpful?

Solution

I could make it work with Query(Linq) like this;

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

but I would like to see if anyone has an example on QueryOver

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top