I've been trying to interpret the answers to similar questions but haven't been able to make it work.
I have a list of activities, and each activity as a list of participants. Here are the mappings:
<class name="Activity" lazy="false">
<id name="ID">
<generator class="guid" />
</id>
<list name="Participants">
<key column="Activity" />
<index column="Ord" />
<many-to-many column="Contact" class="Model.Contact" />
</list>
<property name="Timestamp" />
</class>
<class name="Contact" lazy="false">
<id name="ID">
<generator class="guid" />
</id>
<property name="Name" />
</class>
I am currently retrieving the activities ten at a time with this criteria:
var crit = ModelSession.Current.CreateCriteria<Activity>()
.AddOrder(Order.Desc("Timestamp"))
.SetFirstResult(start)
.SetMaxResults(count);
Now I need to retrieve only those activities in which a particular person participated, in other words: where Contact.Name like '%some_name%'. In raw SQL I'd probably write something like this:
select * from Activity where ID in (select p.Activity from Participants p,
Contact c where p.Contact=c.ID and c.Name like '%some_name%')
Any idea how to do this, with HQL or ICriteria, in a way that lets me keep the paged results and ordering? Many thanks!