Hi. I'm using Query By Example and I have two problems:
1) The SQL generated by ICriteria.List() is using the DateTime fields. I've used ExcludeNulls() and ExcludeZeroes(), but the DateTime fields still there.
The code:
Code:
private IList ListByExample(object sample)
{
ISession session = _factory.OpenSession();
ICriteria criteria = session.CreateCriteria(sample.GetType());
Example ex = Example.Create(sample);
ex.ExcludeNulls();
ex.ExcludeZeroes();
criteria.Add(ex);
return criteria.List();
}
The SQL generated:
Code:
SELECT ... FROM ... WHERE (this.CLI_DATAMAIORFATURA = '0001-01-01 00:00:00' and this.ATI_ID = '3' and this.CLI_DATAPRIMEIRACOMPRA = '0001-01-01 00:00:00' and ...)
2) With the same code above, NHibernate generates the SQL using just the properties or just the Composite-Id (or a simple Id) as example.
How can I do to get a list of objects by example using the Id and Properties as example at the same query?
Thanks!