can i use an existing ado.net transaction?

22 views
Skip to first unread message

kor

unread,
Apr 6, 2012, 9:07:38 AM4/6/12
to nhusers
hi all, i'm using the last nh version with firebird net provider.

in a single place i need to initialize by myself the transaction to
use becouse i need to use same firebird specific options.

i tried to do that

using(ISession session = ...open nh session)
{
var conn = session.Connection as FbConnection;
using(DbTransaction tx = conn.BeginTransaction(//fb specifc options)
{
//work with nh session
tx.Commit();
}
}

but this doesnt work becouse there's an exception becouse the inner fb
command generated and used by nhibernate doent have a transaction set,
so i want kow if there's a way to set the ado.net transation that
nhibernate will use, so samething as

using(ISession session = ...open nh session)
{
var conn = session.Connection as FbConnection;
using(DbTransaction tx = conn.BeginTransaction(//fb specifc options)
{
session.Transaction = //set tx
//work with nh session
tx.Commit();
}
}

is it possible? thanks

Fabio Maulo

unread,
Apr 7, 2012, 5:24:04 PM4/7/12
to nhu...@googlegroups.com
That is not the right way to do it because the custom transaction management will give you some other headaches.
The best way is the implementation of NHibernate.Transaction. ITransactionFactory and the configuration of transaction.factory_class with your impl.
Reply all
Reply to author
Forward
0 new messages