Following is the code I am using. Seems pretty simple to me. But I get a NullReferenceException at the last line , the return statement. Here is the stack trace:
FailedSystem.NullReferenceException: Object reference not set to an instance of an object. at NHibernate.Criterion.Junction.ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary
2 enabledFilters) at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetWhereCondition(IDictionary
2 enabledFilters) at NHibernate.Loader.Criteria.CriteriaJoinWalker..ctor(IOuterJoinLoadable persister, CriteriaQueryTranslator translator, ISessionFactoryImplementor factory, CriteriaImpl criteria, String rootEntityName, IDictionary2 enabledFilters) at NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria, String rootEntityName, IDictionary
2 enabledFilters) at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) at NHibernate.Impl.CriteriaImpl.List(IList results) at NHibernate.Impl.CriteriaImpl.List()
public List<Person> Search(string keyword)
{
ICriteria criteria = session.CreateCriteria(typeof (Person));
Disjunction disjunction = Restrictions.Disjunction();
{
// In here, there is a whole lot of business logic adding around 20 conditions to the disjunction
}
criteria.Add(disjunction);
return criteria.List<Person>() as List<Person>;
}