Closed GoogleCodeExporter closed 9 years ago
NH wraps the underlying transaction away from you with no documented way to
grab the IDbTransaction.
There's a hack to get it though. You can enlist a dummy command and grab the
transaction from the command. Ayende gives the code to do that in this blog
post:
http://ayende.com/blog/1583/i-hate-this-code
Original comment by joel.du...@gmail.com
on 19 Sep 2012 at 6:10
Any ideas how to fix this problem?
Original comment by fedoseev...@gmail.com
on 7 Aug 2014 at 8:44
By... using the hack already posted?
http://ayende.com/blog/1583/i-hate-this-code
I'm not planning on taking a dependency on NHibernate to automate it, but you
could make dapper extension methods on `ISession` that do basically the same,
i.e.
public static IEnumerable<T> Query<T>(this ISession session, ...)
{
IDbConnection conn;
IDbTransaction tran;
using(IDbCommand command = session.Connection.CreateCommand())
{
session.Transaction.Enlist(command);
conn = command.Connection;
tran = command.Transaction;
}
return conn.Query<T>(..., transaction: tran);
}
Not something I think we can solve inside the library, though - unless someone
wants to propose a Dapper.NHibernate...
Original comment by marc.gravell
on 7 Aug 2014 at 10:04
Thank you. I will try this solution. If it would be ok - I'll contribute
Dapper.NHibernate. why not :)
Original comment by fedoseev...@gmail.com
on 8 Aug 2014 at 1:22
Original issue reported on code.google.com by
b...@planetcloud.co.uk
on 15 Oct 2011 at 3:05