Hi,
can anyone assist with the following.
I have the following relationship set up within NHibernate:
I have a top-level 'notification' object.
under the 'notification' I have a NotificationPrimaryAddressee object (one to many)
under the NotificationPrimaryAddressee I have a user object (one to many)
I want to use a criteria/fetchmode expression to return all Notification Primary Addressee's and Users under the main notification object, but unfortunately the code I am using only returns the top-level Notification object.
Here's my code:-
ICriteria criteria = session.CreateCriteria(typeof(DataModel.Notification)); criteria.AddOrder(Order.Desc("NotificationDate") ); criteria.CreateAlias("NotificationPrimaryAddressees","A"); criteria.CreateAlias("A.User","AU"); criteria.SetFetchMode("A", FetchMode.Join); criteria.SetFetchMode("AU", FetchMode.Join); criteria.SetResultTransformer(CriteriaUtil.DistinctRootEntity);
I have also tried the above without aliases, but that doesn't seem to make any difference. Can anyone please tell me what I am doing wrong?
|