Hi,
I have two Classes (User and Line), which are in an n:m relationship. A Line has an Id, so I tried this query to get all the Line-Ids of an user:
Code:
DetachedCriteria lineOfUser = DetachedCriteria.For(typeof(User), "user")
.CreateCriteria("Line", "userLines")
.SetProjection(Projections.Property("userLines.Id"))
.Add(Expression.Eq("user.Id", _CUSTOMER_ID));
lineOfUser.GetExecutableCriteria(session).List();
but this gives me an error:
NHibernate.QueryException: could not resolve property: Id of: NHibernateQueries.Line
So in desperation I did the following: I refactored Line, so that the Id is now called LineId and all over sudden this
Code:
DetachedCriteria lineOfUser = DetachedCriteria.For(typeof(User), "user")
.CreateCriteria("Line", "userLines")
.SetProjection(Projections.Property("userLines.LineId"))
.Add(Expression.Eq("user.Id", _CUSTOMER_ID));
Does work! Interesting why the first doesn't work ...
BTW: I#m using NHibernate 1.2.1.400