views:

15

answers:

0

I have a Class like below

public class Customer
{
    public virtual int ID { get; set; }
    public virtual IList<LokalPortalen.Domain.Entity.CustomerLocationType> CustomerLocationTypes { get; set; }
    public virtual ZipCode ZipCode { get; set; }

    public Customer()
    {
        CustomerLocationTypes = new List<LokalPortalen.Domain.Entity.CustomerLocationType>();
    }

I want to query the class based on a list on LokalPortalen.Domain.Entity.CustomerLocationType but it won't work.

My Query looks like below. The search based on a List works well but i cant see how i can query the CustomerLocationTypes based on a List

using (var sessionFactory = LokalPortalData.GetSession())
{
   var store = sessionFactory.CreateCriteria(typeof(LokalPortalen.Domain.Entity.Customer));
   Junction disjunction = Restrictions.Disjunction();    
   if (zipCodes.Count > 0)
   {
     foreach (LokalPortalen.Domain.Entity.ZipCode zipCode in zipCodes)
     {
       ICriterion criterion = Restrictions.Eq("ZipCode", zipCode);  
       disjunction.Add(criterion);
     }
     store.Add(disjunction);
   }
   Junction disjunction1 = Restrictions.Disjunction();  
   if (locationTypes.Count>0)
   {
     foreach (LokalPortalen.Domain.Entity.LocationType locationType in locationTypes)
     {
       ICriterion criterion = Restrictions.Eq("CustomerLocationTypes", locationType);  
       disjunction1.Add(criterion);
     }
    store.Add(disjunction1);
   }
   return (store.List<LokalPortalen.Domain.Entity.Customer>()).ToList<LokalPortalen.Domain.Entity.Customer>();

}