I got the impression that you recreate your IsessionFactory over and over again for each request/every call to your data layer? Creating an ISessionFactory is an expansive op. Create the instance in some start up code for your web app and reuse it.
-----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 8bit Sent: den 19 november 2008 14:18 To: nhusers Subject: [nhusers] New, Need Help with ISession/Configuration I'm just trying to get a grasp on the fundamentals here. I'm trying to figure out the best way to configure the ISessionFactory/ISession for my ASP.NET application. I'm just afraid that I might be leaving some connection open or perhaps implementing this the wrong way. So, in my data layer, I have a base class: Protected _sessions As ISessionFactory Public Sub New() _sessions = ConfigureSessionFactory() End Sub Protected Function ConfigureSessionFactory() As ISessionFactory Return _ (New NHibernate.Cfg.Configuration()).Configure ().BuildSessionFactory() End Function And here is a sample of how I'm using a method in the "Tag" data layer class: Public Function GetAllTags() As IList(Of String) Dim tags As IList(Of String) = Nothing Dim session As ISession = Nothing Try session = _sessions.OpenSession() tags = session.CreateQuery("select t.Name from Tag t group by t.Name order by t.Name") _ .List(Of String)() Finally session.Close() End Try Return tags End Function Does this look ok? Any suggestions in regards to ISessionFactory/ ISession? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
