I just started learning NHibernate 2 days ago and I'm looking for a CRUD method that I wrote based on a tutorial. My insertion method:
using (ISession session = Contexto.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(noticia);
transaction.Commit();
session.Close();
}
The full "Contexto" code is here: http://codepaste.net/mrnoo5
My question is: do I really need to use the transaction ITransaction = session.BeginTransaction () and transaction.Commit (); ?
I ask for this because I tested running the web application without these two lines, and I successfully inserted new entries.
If possible, can someone explain to me the purpose of Itransaction and the Commit method too?
thank
source
share