Tutorial :Where to reference session.BeginTransaction?


What is the dll that must be used? Where can I have it?

I am using Nhibernate, can I use it with NHibernate?


BeginTransaction() is a method on the NHibernate session. It's part of the NHibernate.dll in the current version of NHibernate.


Source: http://www.fincher.org/tips/Languages/NHibernate.shtml

using (ISession session = OpenSession()) {    using (ITransaction transaction = session.BeginTransaction()) {      IQuery query = session.CreateQuery("FROM Pet WHERE PetName = 'Rosie'");      Pet pet = query.List<Pet>()[0];      session.Delete(pet);      transaction.Commit();    }  }      static ISessionFactory SessionFactory;  static ISession OpenSession() {    if (SessionFactory == null) //not threadsafe        { //SessionFactories are expensive, create only once      Configuration configuration = new Configuration();      configuration.AddAssembly(Assembly.GetCallingAssembly());      SessionFactory = configuration.BuildSessionFactory();    }    return SessionFactory.OpenSession();  }  


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »