Reputation: 1835
We are usin NHibernate as our DAL for the domain model. At the end of a bulk process I want to do some actions using the NHibernate DAL
Something like:
public void BulkUpdate()
{
var connection = new sqlConnection(“connectonstring”);
var transaction = connection.BeginTransaction();
// Do Bulk Stuff
var session = SessionFactory.OpenSession(connection);
var result = session.Query<DomainClass>();
// Do Stuff with Result
transaction.Commit();
connection.Close();
}
The read attempt of NHibernate fails, because it tries to use a command object, that has no transaction set. But I do not know of a way to pass the transaction object to it.
Any Nhibernate guru's out there?
Upvotes: 1
Views: 1554
Reputation: 12680
I think this approach might work but don't have time right now to verify it:
session.BeginTransaction()
session.Connection
property to perform the bulk stuffsession
and commit as appropriateUpvotes: 3