I have a QueryOver by JoinQueryOver In Nhibernate 3.1
The Person class has a association by Identity class (one-to-one) Code is a field of Person class and FirstName is a field of Identity class.
var q = SessionInstance.QueryOver<Person>() .Where(p => p.Code.IsLike(code,MatchMode.Start)) .Full.JoinQueryOver(p => p.Identity); if (!String.IsNullOrEmpty(firstName)) q = q.Where(i => i.FirstName.IsLike(firstName, MatchMode.Anywhere)); return q.List<Person>(); that result is correct but, there is a problem. The search does not include items by null value for Code field in Person class. I corrected to following query.
var q = SessionInstance.QueryOver<Person>() .Full.JoinQueryOver(p => p.Identity); if (!String.IsNullOrEmpty(Code)) q = q.Where(i => i.Person.Code.IsLike(code, MatchMode.Start)); if (!String.IsNullOrEmpty(firstName)) q = q.Where(i => i.FirstName.IsLike(firstName, MatchMode.Anywhere)); return q.List<Person>(); Now i have a runtime error by this message:
could not resolve property: Identity.Code of: MyNameSpace.Domain.Entities.Identity
in a query by join between two class, How can add two condition(where) by if.
(if parameter != null)