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
- XmlComment.cs
- PreviewKeyDownEventArgs.cs
- DataTableNewRowEvent.cs
- XmlNamespaceManager.cs
- GenericTextProperties.cs
- DataSourceCacheDurationConverter.cs
- TextOptionsInternal.cs
- ManagementPath.cs
- PrintDialogException.cs
- basecomparevalidator.cs
- CompoundFileIOPermission.cs
- TileBrush.cs
- BinaryMessageEncodingElement.cs
- InkPresenterAutomationPeer.cs
- SystemInfo.cs
- TableLayoutRowStyleCollection.cs
- DataServiceQueryException.cs
- SpeechEvent.cs
- CodeChecksumPragma.cs
- ObservableDictionary.cs
- InvokeProviderWrapper.cs
- SqlDataSourceCommandEventArgs.cs
- SqlServer2KCompatibilityAnnotation.cs
- MetafileHeader.cs
- XmlDataSource.cs
- SqlReferenceCollection.cs
- RSAPKCS1KeyExchangeFormatter.cs
- FrameAutomationPeer.cs
- XmlSchemaExternal.cs
- ViewCellSlot.cs
- HttpContext.cs
- Function.cs
- SafeRightsManagementQueryHandle.cs
- WebBrowserNavigatingEventHandler.cs
- ExpressionWriter.cs
- TCPClient.cs
- SvcMapFileLoader.cs
- TextDecoration.cs
- UdpRetransmissionSettings.cs
- AsyncDataRequest.cs
- TypeSchema.cs
- LayeredChannelListener.cs
- HttpStreamXmlDictionaryReader.cs
- UiaCoreApi.cs
- ConfigurationSectionGroupCollection.cs
- KnownBoxes.cs
- DataBoundControlParameterTarget.cs
- StrokeRenderer.cs
- EntityModelSchemaGenerator.cs
- XsltContext.cs
- MarshalDirectiveException.cs
- XamlInt32CollectionSerializer.cs
- MouseWheelEventArgs.cs
- ThreadAbortException.cs
- EdmToObjectNamespaceMap.cs
- XPathAncestorQuery.cs
- Journal.cs
- XmlQueryContext.cs
- IUnknownConstantAttribute.cs
- SymmetricAlgorithm.cs
- ScrollableControl.cs
- InternalRelationshipCollection.cs
- EntityClientCacheEntry.cs
- RegexGroup.cs
- FormParameter.cs
- MenuItem.cs
- WindowPattern.cs
- DataControlFieldTypeEditor.cs
- BidirectionalDictionary.cs
- ETagAttribute.cs
- SqlCacheDependencyDatabase.cs
- MsdtcClusterUtils.cs
- DataSourceDesigner.cs
- CompilerParameters.cs
- StringFormat.cs
- HtmlMeta.cs
- ProfileParameter.cs
- RectKeyFrameCollection.cs
- RuntimeEnvironment.cs
- SecureUICommand.cs
- DataControlFieldCollection.cs
- TaskForm.cs
- CombinedGeometry.cs
- AutomationPatternInfo.cs
- x509utils.cs
- PointAnimationUsingPath.cs
- ToolBarOverflowPanel.cs
- WFItemsToSpacerVisibility.cs
- X509CertificateCollection.cs
- RoutedEventConverter.cs
- SamlDoNotCacheCondition.cs
- SamlConstants.cs
- BaseParaClient.cs
- DataPager.cs
- XamlVector3DCollectionSerializer.cs
- PasswordRecovery.cs
- StoreItemCollection.Loader.cs
- DelegateArgument.cs
- OverrideMode.cs
- EntityDataSourceQueryBuilder.cs