/// <summary> /// Initializes a new instance of the <see cref="UnitOfWorkScope"/> class. /// </summary> public UnitOfWorkScope() { if ( currentScope == null ) { DbContext = new RockContext(); isDisposed = false; currentScope = this; } }
/// <summary> /// Initializes a new instance of the <see cref="UnitOfWorkScope"/> class using a custom dbContext /// </summary> public UnitOfWorkScope(DbContext context) { if ( currentScope == null ) { DbContext = context; isDisposed = false; currentScope = this; } }
/// <summary> /// Initializes a new instance of the <see cref="UnitOfWorkScope"/> class using a custom dbContext /// </summary> public UnitOfWorkScope(DbContext context) { if (currentScope == null) { DbContext = context; isDisposed = false; currentScope = this; } }
/// <summary> /// Initializes a new instance of the <see cref="UnitOfWorkScope"/> class. /// </summary> public UnitOfWorkScope() { if (currentScope == null) { DbContext = new RockContext(); isDisposed = false; currentScope = this; } }
/// <summary> /// Initializes a new instance of the <see cref="UnitOfWorkScope"/> class. /// </summary> /// <param name="saveAllChangesAtScopeEnd">if set to <c>true</c> changes should be saved at scope end.</param> public UnitOfWorkScope( bool saveAllChangesAtScopeEnd ) { if ( currentScope != null && !currentScope.isDisposed ) throw new InvalidOperationException( "ObjectContextScope instances can not be nested" ); SaveAllChangesAtScopeEnd = saveAllChangesAtScopeEnd; objectContext = new RockContext(); isDisposed = false; //Thread.BeginThreadAffinity(); --Not supported with Medium Trust currentScope = this; }
/// <summary> /// Initializes a new instance of the <see cref="UnitOfWorkScope"/> class. /// </summary> /// <param name="saveAllChangesAtScopeEnd">if set to <c>true</c> changes should be saved at scope end.</param> public UnitOfWorkScope(bool saveAllChangesAtScopeEnd) { if (currentScope != null && !currentScope.isDisposed) { throw new InvalidOperationException("ObjectContextScope instances can not be nested"); } SaveAllChangesAtScopeEnd = saveAllChangesAtScopeEnd; objectContext = new RockContext(); isDisposed = false; //Thread.BeginThreadAffinity(); --Not supported with Medium Trust currentScope = this; }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!isDisposed) { if (disposing) { if (DbContext != null) { DbContext.Dispose(); currentScope = null; } } isDisposed = true; } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (!isDisposed) { currentScope = null; //Thread.EndThreadAffinity(); -- Not supported with Medium Trust if (SaveAllChangesAtScopeEnd) { objectContext.SaveChanges(); } objectContext.Dispose(); isDisposed = true; } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!isDisposed) { if (disposing) { currentScope = null; //Thread.EndThreadAffinity(); -- Not supported with Medium Trust if (SaveAllChangesAtScopeEnd) { objectContext.SaveChanges(); } objectContext.Dispose(); } isDisposed = true; } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose( bool disposing ) { if ( !isDisposed ) { if ( disposing ) { currentScope = null; //Thread.EndThreadAffinity(); -- Not supported with Medium Trust if ( SaveAllChangesAtScopeEnd ) { objectContext.SaveChanges(); } objectContext.Dispose(); } isDisposed = true; } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose( bool disposing ) { if ( !isDisposed ) { if ( disposing ) { if ( DbContext != null ) { DbContext.Dispose(); currentScope = null; } } isDisposed = true; } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if ( !isDisposed ) { currentScope = null; //Thread.EndThreadAffinity(); -- Not supported with Medium Trust if ( SaveAllChangesAtScopeEnd ) { objectContext.SaveChanges(); } objectContext.Dispose(); isDisposed = true; } }