NHibernate selecting from a many to many collection?

Try using Aliases like: ClientContact Cont = null; RequestType Req = null; var x = session. QueryOver(() => Cont) . Where(() => Cont.ID == ContactId) .

JoinAlias(() => Cont. DefaultRequests, ()=> Req, JoinType. LeftOuterJoin) .

Select(ignore => Req. Id) // ().

There seems to be a problem with the Select(() => Req. Id). It wants a ClientContact.

Any ideas how to project into the collection of RequestTypes? – CRG Apr 1 at 8:53 I added an HQL version to the post. It works, but I really would like to know how to do this strongly typed.

– CRG Apr 1 at 8:56 @CRG I suggested an edit to Faber's answer. Until it is accepted, use . Select(ignore => Req.Id).List(); I tested that and it should work.

– Florian Lim Apr 1 at 9:34 Awesome thanks! – CRG Apr 1 at 1:35.

You have to turn it around. I believe Faber's answer will also work well. So you do not have to turn it around.(But you could.) ClientContact cAlias = null; var x = Session.QueryOver() .

JoinAlias(rt => rt. ClientContacts, () => cAlias) . Where(() => cAlias.

Id == ContactId) . Select(rt => rt.Id) // not sure what you want returned here, Id or the object) .List().

I can't navigate from RequestType to ClientContacts. I'm only after the Ids at this stage. – CRG Apr 1 at 8:23 @CRG Then Faber's answer will probably give you the desired result.

– Florian Lim Apr 1 at 8:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions