Hi.
I'm using NH 1.2 Alpha and would like to know why my QBE queries using associations does not work.
I'm using the following query:
Code:
public static IList<Cliente> List(int idRepresentante)
{
Representante representante = RepresentanteDAL.Get(idRepresentante);
Cliente cliente = new Cliente();
cliente.Representante = representante;
return BaseDAL.List<Cliente>(cliente, null);
}
My BaseDAL.List<T> is here:
Code:
public static IList<T> List<T>(object sample, string propName)
{
ICriteria criteria = NHibernateHelper.Session.CreateCriteria(sample.GetType());
Example example = Example.Create(sample);
example.ExcludeZeroes();
criteria.Add(example);
if (propName != null)
{
order order = new Order(propName, false);
criteria.AddOrder(order);
}
return criteria.List<T>();
}
This query (using an object as example) returns all records. The "where" clause is "Where (1=1)".
I've made a test using EqExpression and it has worked fine. The test is:
Code:
public static IList<Cliente> List(int idRepresentante)
{
Representante representante = RepresentanteDAL.Get(idRepresentante);
ICriteria criteria = NHibernateHelper.Session.CreateCriteria(typeof(Cliente));
criteria.Add(new EqExpression("Representante", representante));
return criteria.List<Cliente>();
}
So, the first way is wrong? I can't use association when I use object by example?
Thanks :~)