Chiefos wrote:
Firstly, can I only use NHibernate to map objects or is it possible to perform adhoc queries that simple return a data set of some type? In this case I simply want a list of int returning.
Yes, you can use NHibernate for ad-hoc queries that return things other than your objects. Just use the SELECT clause in your HQL such as "SELECT v.VenueID FROM Venue v WHERE ..."
Chiefos wrote:
Secondly, can I still use my SProc with NHibernate? Without going into too much info there's quite a lot of db calls happen in this SProc to return the data I want. Moving this to the application side would mean either alot of round trips to the db or a single trip to retrieve a massive data set which could be queried in mem. I dont really want to do either and would rather this type of processing stayed at the db layer.
Yes, you can do this as well. See the following link from the NHibernate documentation for more information:
http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html_single/#sp_queryYou could also read a blog post from Oren Eini (Ayende @ Rahien):
http://www.ayende.com/Blog/archive/7263.aspxChiefos wrote:
Thirdly, if i can get NHibernate to use my SProc to return a list of venueIDs could I then use this with a query to join on the activities i.e.
//Normal SQL
SELECT A.* FROM [Activities] as A
INNER JOIN [ActivitiesToVenues] as AtoV on A.ID = AtoV.ActivityID INNER JOIN [Venues] as V on AtoV.VenueID = V.ID
WHERE VenueID IN {results of my SProc}
Yes you can do this too, but it will require a second round trip. First run the procedure to return the list of VenueID values and then run a new NHibernate query providing just the list of the VenueIDs.