I'm trying to create the equivalent of the below using NHibernate. I've done all the mappings using fluent and I can do the basic queries just fine but I have no idea how to do this.
-**Product Table**
Reference
Title
Subjects (Many to Many relationship)
Price
-**Subject table**
SubjectID
Name
-**SubjectToProductMapping Table**
Reference
SubjectID
Now I need to do this:
SELECT *
FROM Product
WHERE Reference IN
(Select Reference FROM SubjectToProductMapping WHERE SubjectID = @SubjectID)
Baring in mind the Product table has been simplified a great deal for the post and that I would prefer to use an IN statement to keep the rest of the query simpler. I would ideally like to create the query using Criteria becuase I will be using Criteria to page the results.
Thanks in advance