In my model I have Games. Each Game has an Event associated with it, which is mapped as a many-to-one association.
When I query for Games, within event with given EventId (different than its DB-PrimaryKey-id) NHibernate issues the following query for each and every Game:
NHibernate: SELECT event0_.Id as Id8_0_, event0_.EventId as EventId8_0_ FROM Events event0_ WHERE event0_.EventId=@p0; @p0 = '4'
In my mapping (and in the DB generated from the mapping) EventId has a Unique constraint. How do I tell NHibernate that it should fetch the Event only once for given EventId, not issue the same exact query N times for N Games?