What is the best approach to managing NHibernate transaction using Autofac within web application?
My approach to session is
builder.Register(c => c.Resolve<ISessionFactory>().OpenSession())
.ContainerScoped();
For ITransaction, I have found an example on Google Code, but it relies on HttpContext.Current.Error when deciding whether to rollback.
Is there a better solution? And what scope NHibernate transaction should have?
I posted this a while ago:
http://groups.google.com/group/autofac/browse_thread/thread/f10badba5fe0d546/e64f2e757df94e61?lnk=gst&q=transaction#e64f2e757df94e61
Modified, so that the interceptor has logging capability and [Transaction] attribute can also be used on a class.