hello
Can I use TransactionScope with NHibernate like this? Note one connection is Nhibernate's ISession and the other is IDbConnection from .NET framework.
Code:
public override long Save(ref IGenericTO oUser)
{
long nGeneratedId = Constants.SAVEFAILED;
TransactionScope oScope = null;
IDbConnection oConn = null;
GenericObjectDAO oGenericObjDAO = null;
if (oUser == null || !(oUser is SystemUser))
{
return Constants.SAVEFAILED;
}
try
{
using (oScope = new TransactionScope())
{
nGeneratedId = (long)HibernateDBSession.Save(oUser);
oADONetConn = DBUtil.GetDefaultDBConnection();
oGenericObjDAO = new GenericObjectDAO(oConn);
((SystemUser)oUser).Properties = oGenericObjDAO.LoadGenericObject(oUser.Id);
oScope.Complete();
}
}
catch (Exception ex)
{
// do something
}
return nGeneratedId;
}
Thanks