Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / EntityClient / EntityTransaction.cs / 2 / EntityTransaction.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- 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 [....], [....] //--------------------------------------------------------------------- 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
- RunClient.cs
- CharStorage.cs
- Attributes.cs
- ArraySortHelper.cs
- ReversePositionQuery.cs
- NetStream.cs
- RawContentTypeMapper.cs
- ComponentChangedEvent.cs
- ClientSettingsProvider.cs
- StatusBarPanelClickEvent.cs
- DigitShape.cs
- BreakRecordTable.cs
- XmlStreamStore.cs
- ConfigXmlText.cs
- TransformValueSerializer.cs
- HttpProcessUtility.cs
- MethodRental.cs
- BinaryCommonClasses.cs
- HttpContextServiceHost.cs
- HostProtectionException.cs
- TargetInvocationException.cs
- ExceptionRoutedEventArgs.cs
- DoubleCollection.cs
- InputLanguageManager.cs
- XmlBinaryReaderSession.cs
- WindowsHyperlink.cs
- Underline.cs
- System.Data_BID.cs
- ExitEventArgs.cs
- NetTcpSection.cs
- DataServiceEntityAttribute.cs
- DataKey.cs
- oledbmetadatacollectionnames.cs
- DifferencingCollection.cs
- EdmTypeAttribute.cs
- ConfigXmlText.cs
- DataControlImageButton.cs
- RequestCacheValidator.cs
- Input.cs
- DataGridPageChangedEventArgs.cs
- SchemaElementDecl.cs
- X509CertificateStore.cs
- EmbeddedObject.cs
- ExceptionCollection.cs
- XmlWrappingWriter.cs
- CompositeClientFormatter.cs
- PathFigure.cs
- TextElement.cs
- PlainXmlWriter.cs
- XmlCharCheckingWriter.cs
- MsmqProcessProtocolHandler.cs
- TextEffect.cs
- TdsRecordBufferSetter.cs
- DrawToolTipEventArgs.cs
- PointConverter.cs
- CallContext.cs
- TextServicesLoader.cs
- Table.cs
- MembershipSection.cs
- FileSystemWatcher.cs
- StatusBar.cs
- ContainerSelectorGlyph.cs
- CheckoutException.cs
- EventSource.cs
- PassportAuthentication.cs
- FilteredSchemaElementLookUpTable.cs
- ColorPalette.cs
- TabRenderer.cs
- ThumbAutomationPeer.cs
- WebConfigurationHostFileChange.cs
- TimeZone.cs
- UIElement3DAutomationPeer.cs
- TrustManagerPromptUI.cs
- IconConverter.cs
- XmlMemberMapping.cs
- Exception.cs
- EntityTransaction.cs
- XmlAttributeProperties.cs
- MiniMapControl.xaml.cs
- JsonObjectDataContract.cs
- TypeConstant.cs
- GAC.cs
- EntityDesignerUtils.cs
- SecurityState.cs
- _NativeSSPI.cs
- FilteredDataSetHelper.cs
- HashMembershipCondition.cs
- IriParsingElement.cs
- GenericNameHandler.cs
- CryptoApi.cs
- MessagingDescriptionAttribute.cs
- HttpRequestBase.cs
- Pointer.cs
- EdmPropertyAttribute.cs
- TypeListConverter.cs
- _CacheStreams.cs
- VerbConverter.cs
- Mappings.cs
- InvalidDataException.cs
- DateTime.cs