Hi every Body,
I'm using The CodeSmith Generator professional edition V5.05 with NHibernate Framework (VB.net)
I generate all my classes with no problems, but I want to understand what is the significance of using the ManagerObjects classes.
I have a EMPLOYEE table in my database ; after generation I obtain the following classes :
EMPLOYEE.vb , EMPLOYEEManager.vb and base classes.
So I can perform a saveOrUpdate transaction using 2 methods :
Method1 : Using the ManagerObjects classes
Dim managerFac As IManagerFactory = New ManagerFactory()
Try
managerFac.GetEMPLOYEEManager.Session.BeginTransaction()
managerFac.GetEMPLOYEEManager.SaveOrUpdate(CType(currentObject, EMPLOYEE))
managerFac.GetEMPLOYEEManager.Session.CommitTransaction()
Catch ex As Exception
managerFac.GetEMPLOYEEManager.Session.RollbackTransaction()
MessageBox.Show(ex.Message)
End Try
Method2 : Without Using the ManagerObjects classes
Dim config As New NHibernate.Cfg.Configuration
Dim sessionFactory As NHibernate.ISessionFactory = config.Configure.BuildSessionFactory
Dim session As NHibernate.ISession
Dim transaction As NHibernate.ITransaction
Try
ModuleApplication.session = sessionFactory.OpenSession()
ModuleApplication.transaction = ModuleApplication.session.BeginTransaction()
ModuleApplication.transaction.Begin()
ModuleApplication.session.SaveOrUpdate(CType(currentObject, EMPLOYEE))
ModuleApplication.transaction.Commit()
Catch ex As Exception
ModuleApplication.transaction.Rollback()
MessageBox.Show(ex.Message)
End Try
Please Help Me to understand what is the difference between those 2 methods, and what is the significance of using the ManagerObjects classes.
Thanks in advance Wink