/// <summary> /// Occurs before the action method is invoked. /// </summary> /// <param name="actionContext">The action context.</param> public override void OnActionExecuting(HttpActionContext actionContext) { base.OnActionExecuting(actionContext); global::NHibernate.ISession session = NHibernateSession.CurrentFor(this.GetEffectiveFactoryKey()); if (this.IsolationLevel != IsolationLevel.Unspecified) { session.BeginTransaction(this.IsolationLevel); } else { session.BeginTransaction(); } }
public void FixtureSetup() { var provider = new NHibernateProvider(); _config = provider.CreateConfiguration(); _sessionFactory = provider.CreateSessionFactory(_config); _session = _sessionFactory.OpenSession(); provider.ExportSchema(_config, _session.Connection); using (var trans = _session.BeginTransaction()) { var modelCreator = new NHibernateQueryingModel(); modelCreator.CreateModel(_session); trans.Commit(); } _query = new QueryAdapter(_session); QueryableExtensions.EagerFetchingProvider = new EagerFetchingProvider(); QueryableExtensions.LazyQueryingProvider = new LazyResultProvider(); QueryableExtensions.AsyncQueryingProvider = new AsyncQueryProvider(); }
private void EnsureTransaction() { if (transaction == null || !transaction.IsActive || transaction.WasCommitted || transaction.WasRolledBack) { transaction = session.BeginTransaction(); } }
public NhProviderTransaction(global::NHibernate.ISession nhSession, bool isNestedInActiveTransaction = false) { _nhSession = nhSession; _isNestedInActiveTransaction = isNestedInActiveTransaction; //_nhTransaction = nhSession.Transaction; IncrementNestingLevel(); if (!isNestedInActiveTransaction) { _nhTransaction = nhSession.BeginTransaction(); } else { _nhTransaction = nhSession.Transaction; } LogHelper.TraceIfEnabled <NhProviderTransaction>("Constructing transaction {0} on instance {1}", () => _nhTransaction.GetHashCode(), () => GetHashCode()); //if (isNestedInActiveTransaction) //{ // _nhTransaction = NhSession.BeginTransaction(System.Data.IsolationLevel.RepeatableRead); //} //else //{ // _nhTransaction = NhSession.Transaction; //} Begin(); }
public void TransactionAdapter_can_create_and_commit_a_transaction() { var tran = _session.BeginTransaction(); using (var sut = new TransactionAdapter(tran)) { sut.Commit(); Assert.That(tran.WasCommitted, Is.True); } tran?.Dispose(); }
private void EnsureTransaction() { // start new transaction if // 1) No transaction is initiated yet // 2) Existing transaction isn't active // 3) Existing transaction was committed // 4) Existing transaction was rolled back if (transaction == null || !transaction.IsActive || transaction.WasCommitted || transaction.WasRolledBack) { transaction = session.BeginTransaction(); } }