foxonline wrote:
Code :
ICriteria criteria = session.CreateCriteria(typeof(ChatInfoEO));
criteria.Add(Expression.Like("UserInfo.UserName","2"));
IList list = criteria.List();
The expression you specified uses an implicit join between the ChatInfoEO and UserInfo classes. Implicit joins are not supported by the ICriteria interface and the style of property access you used will only work when dereferencing components (e.g. UserInfo is mapped as a component, not a class).
I believe the following criteria will achieve your desired behavior:
Code:
session.CreateCriteria(typeof(ChatInfoEO))
.CreateCriteria("UserInfo")
.Add(Expression.Like("UserName","2"))
.List()
See
http://www.hibernate.org/hib_docs/nhibernate/html/querycriteria.html for more information.