Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / EntityClient / EntityTransaction.cs / 1305376 / EntityTransaction.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Text; using System.Data; using System.Data.Common; using System.Diagnostics; namespace System.Data.EntityClient { using Metadata.Edm; ////// Class representing a transaction for the conceptual layer /// public sealed class EntityTransaction : DbTransaction { private EntityConnection _connection; private DbTransaction _storeTransaction; ////// Constructs the EntityTransaction object with an associated connection and the underlying store transaction /// /// The EntityConnetion object owning this transaction /// The underlying transaction object internal EntityTransaction(EntityConnection connection, DbTransaction storeTransaction) : base() { Debug.Assert(connection != null && storeTransaction != null); this._connection = connection; this._storeTransaction = storeTransaction; } ////// The connection object owning this transaction object /// public new EntityConnection Connection { get { // follow the store transaction behavior return ((null != _storeTransaction.Connection) ? _connection : null); } } ////// The connection object owning this transaction object /// protected override DbConnection DbConnection { get { // follow the store transaction behavior return ((null != _storeTransaction.Connection) ? _connection : null); } } ////// The isolation level of this transaction /// public override IsolationLevel IsolationLevel { get { return this._storeTransaction.IsolationLevel; } } ////// Gets the DbTransaction for the underlying provider transaction /// internal DbTransaction StoreTransaction { get { return this._storeTransaction; } } ////// Commits the transaction /// public override void Commit() { try { this._storeTransaction.Commit(); } catch (Exception e) { if (EntityUtil.IsCatchableExceptionType(e)) { throw EntityUtil.Provider(@"Commit", e); } throw; } this.ClearCurrentTransaction(); } ////// Rolls back the transaction /// public override void Rollback() { try { this._storeTransaction.Rollback(); } catch (Exception e) { if (EntityUtil.IsCatchableExceptionType(e)) { throw EntityUtil.Provider(@"Rollback", e); } throw; } this.ClearCurrentTransaction(); } ////// Cleans up this transaction object /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources protected override void Dispose(bool disposing) { if (disposing) { this.ClearCurrentTransaction(); this._storeTransaction.Dispose(); } base.Dispose(disposing); } ////// Helper method to wrap EntityConnection.ClearCurrentTransaction() /// private void ClearCurrentTransaction() { if (_connection.CurrentTransaction == this) { _connection.ClearCurrentTransaction(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Text; using System.Data; using System.Data.Common; using System.Diagnostics; namespace System.Data.EntityClient { using Metadata.Edm; ////// Class representing a transaction for the conceptual layer /// public sealed class EntityTransaction : DbTransaction { private EntityConnection _connection; private DbTransaction _storeTransaction; ////// Constructs the EntityTransaction object with an associated connection and the underlying store transaction /// /// The EntityConnetion object owning this transaction /// The underlying transaction object internal EntityTransaction(EntityConnection connection, DbTransaction storeTransaction) : base() { Debug.Assert(connection != null && storeTransaction != null); this._connection = connection; this._storeTransaction = storeTransaction; } ////// The connection object owning this transaction object /// public new EntityConnection Connection { get { // follow the store transaction behavior return ((null != _storeTransaction.Connection) ? _connection : null); } } ////// The connection object owning this transaction object /// protected override DbConnection DbConnection { get { // follow the store transaction behavior return ((null != _storeTransaction.Connection) ? _connection : null); } } ////// The isolation level of this transaction /// public override IsolationLevel IsolationLevel { get { return this._storeTransaction.IsolationLevel; } } ////// Gets the DbTransaction for the underlying provider transaction /// internal DbTransaction StoreTransaction { get { return this._storeTransaction; } } ////// Commits the transaction /// public override void Commit() { try { this._storeTransaction.Commit(); } catch (Exception e) { if (EntityUtil.IsCatchableExceptionType(e)) { throw EntityUtil.Provider(@"Commit", e); } throw; } this.ClearCurrentTransaction(); } ////// Rolls back the transaction /// public override void Rollback() { try { this._storeTransaction.Rollback(); } catch (Exception e) { if (EntityUtil.IsCatchableExceptionType(e)) { throw EntityUtil.Provider(@"Rollback", e); } throw; } this.ClearCurrentTransaction(); } ////// Cleans up this transaction object /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources protected override void Dispose(bool disposing) { if (disposing) { this.ClearCurrentTransaction(); this._storeTransaction.Dispose(); } base.Dispose(disposing); } ////// Helper method to wrap EntityConnection.ClearCurrentTransaction() /// private void ClearCurrentTransaction() { if (_connection.CurrentTransaction == this) { _connection.ClearCurrentTransaction(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CachedFontFace.cs
- IPAddressCollection.cs
- ProfileParameter.cs
- PasswordDeriveBytes.cs
- RawKeyboardInputReport.cs
- HttpListenerRequestTraceRecord.cs
- TypeDefinition.cs
- AudioFormatConverter.cs
- MemoryRecordBuffer.cs
- Translator.cs
- SingleStorage.cs
- EntityDataSourceWrapperCollection.cs
- CompilerError.cs
- WindowsFont.cs
- SafeLibraryHandle.cs
- TextInfo.cs
- ObjectContextServiceProvider.cs
- MatrixCamera.cs
- InputProcessorProfilesLoader.cs
- BitmapEffectGroup.cs
- UnsafeNativeMethods.cs
- Action.cs
- Vector3DCollection.cs
- KernelTypeValidation.cs
- _ChunkParse.cs
- ScrollEvent.cs
- TableRowCollection.cs
- DataGridViewSelectedColumnCollection.cs
- XmlDataLoader.cs
- IisTraceWebEventProvider.cs
- InputLanguageCollection.cs
- EventLogEntryCollection.cs
- relpropertyhelper.cs
- Clipboard.cs
- HttpPostedFile.cs
- NameValueFileSectionHandler.cs
- Module.cs
- WriteableBitmap.cs
- ProfileProvider.cs
- XmlSubtreeReader.cs
- XmlEntityReference.cs
- XXXOnTypeBuilderInstantiation.cs
- XmlBinaryReader.cs
- ToggleProviderWrapper.cs
- CompilerErrorCollection.cs
- ClientUrlResolverWrapper.cs
- FrameworkContextData.cs
- BaseTransportHeaders.cs
- MessageSecurityOverMsmq.cs
- ObjectTag.cs
- FileInfo.cs
- WebConfigurationHostFileChange.cs
- DictionarySectionHandler.cs
- JournalNavigationScope.cs
- ObjectStorage.cs
- FilterElement.cs
- MemberPath.cs
- RangeContentEnumerator.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- ParagraphVisual.cs
- RelationshipEndCollection.cs
- DrawingVisual.cs
- DiffuseMaterial.cs
- SmtpFailedRecipientException.cs
- XamlTypeWithExplicitNamespace.cs
- CommonDialog.cs
- SqlDataSourceQueryConverter.cs
- DeclarativeCatalogPart.cs
- MobileControlsSectionHandler.cs
- SystemIPGlobalStatistics.cs
- Region.cs
- HyperLinkColumn.cs
- ReachDocumentPageSerializerAsync.cs
- BamlBinaryReader.cs
- ItemMap.cs
- WindowsTooltip.cs
- FontFamilyIdentifier.cs
- CodeIdentifier.cs
- DataControlCommands.cs
- DynamicFilter.cs
- UnionCodeGroup.cs
- ExpandCollapsePattern.cs
- SQLBinaryStorage.cs
- PackageRelationshipSelector.cs
- DateTimePicker.cs
- PageStatePersister.cs
- VectorCollectionValueSerializer.cs
- PrePostDescendentsWalker.cs
- RawKeyboardInputReport.cs
- KoreanCalendar.cs
- UserControlParser.cs
- ControlCachePolicy.cs
- ChtmlPhoneCallAdapter.cs
- CodeSnippetStatement.cs
- RunInstallerAttribute.cs
- XmlQualifiedNameTest.cs
- FontStyleConverter.cs
- CngProperty.cs
- StatusBar.cs
- TraceLevelHelper.cs