learning
learning

Reputation: 11725

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?

Upvotes: 0

Views: 405

Answers (2)

Dion
Dion

Reputation: 954

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

Upvotes: 1

Floyd
Floyd

Reputation: 1918

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();
}

http://www.google.com/search?q=session.begintransaction+nhibernate

Upvotes: 0

Related Questions