Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / DataOracleClient / System / Data / OracleClient / OracleTransaction.cs / 1 / OracleTransaction.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Data.OracleClient
{
using System;
using System.Data;
using System.Data.Common;
using System.Runtime.InteropServices;
using System.Diagnostics;
//---------------------------------------------------------------------
// OracleTransaction
//
// Implements the Oracle Transaction object, which handles local
// transaction requests
//
sealed public class OracleTransaction : DbTransaction {
private OracleConnection _connection;
private int _connectionCloseCount; // The close count of the connection; used to decide if we're zombied
private IsolationLevel _isolationLevel = IsolationLevel.ReadCommitted;
private static int _objectTypeCount; // Bid counter
internal readonly int _objectID = System.Threading.Interlocked.Increment(ref _objectTypeCount);
internal OracleTransaction(OracleConnection connection) : this (connection, IsolationLevel.Unspecified) {}
internal OracleTransaction( OracleConnection connection, IsolationLevel isolationLevel ) {
OracleConnection.VerifyExecutePermission();
//-------------------------------------------------------------------------------------
// pre-condition validation
// ensure we are not attempting to nest transactions. Enforced at runtime by
// OracleInternalConnection.BeginOracleTransaction
Debug.Assert ( connection.TransactionState == TransactionState.AutoCommit );
// SQLHOTFIX# 50003423: setting isolation levels may require that we execute commands on
// the server which will, in turn, rollback any potentially dead transactions and reset
// our state to auto-commit mode. This typically happens when a connection is re-used
// to execute a new command after a previous command associated with a transaction
// has been committed. When we're attempting to begin a new transaction, we need to
// ensure that we've cleared the internal state *before* partially initializing members.
Debug.Assert ( connection.Transaction == null );
//--------------------------------------------------------------------------------------
TransactionState previousState = connection.TransactionState;
if (TransactionState.GlobalStarted == previousState) {
throw ADP.NoLocalTransactionInDistributedContext();
}
_connection = connection;
_connectionCloseCount = connection.CloseCount;
_isolationLevel = isolationLevel;
// SQLBUVSTS 39106: set the transaction state before changing the isolation level
_connection.TransactionState = TransactionState.LocalStarted;
try {
// Tell oracle what the isolation level should be.
switch (isolationLevel) {
case IsolationLevel.Unspecified:
// Take whatever we get from the server
break;
case IsolationLevel.ReadCommitted: {
// DEVNOTE: Most often, this is the default, but it is configurable on the server;
// we should avoid the roundtrip if we can figure out whether this is really
// the default.
using (OracleCommand cmd = Connection.CreateCommand()) {
cmd.CommandText = "set transaction isolation level read committed";
cmd.ExecuteNonQuery();
}
}
break;
case IsolationLevel.Serializable: {
using (OracleCommand cmd = Connection.CreateCommand()) {
cmd.CommandText = "set transaction isolation level serializable";
cmd.ExecuteNonQuery();
}
}
break;
default:
throw ADP.UnsupportedIsolationLevel();
}
}
catch {
// in case of error, revert the transaction state and rethrow
_connection.TransactionState = previousState;
throw;
}
// SQLBUDT# 449125 and SQLHOTFIX# 50003423 - ensure that connection's TransactionState has not been reset
// during initialization of the transaction object.
Debug.Assert(_connection.TransactionState == TransactionState.LocalStarted, "Executing commands to set isolational level has reset the connection's transaction state.");
}
new public OracleConnection Connection {
get {
return _connection;
}
}
override protected DbConnection DbConnection {
get {
return Connection;
}
}
override public IsolationLevel IsolationLevel {
get {
AssertNotCompleted();
if (IsolationLevel.Unspecified == _isolationLevel) {
using (OracleCommand cmd = Connection.CreateCommand()) {
cmd.Transaction = this;
cmd.CommandText = "select decode(value,'FALSE',0,1) from V$SYSTEM_PARAMETER where name = 'serializable'";
Decimal x = (Decimal)cmd.ExecuteScalar();
if (0 == x)
_isolationLevel = IsolationLevel.ReadCommitted;
else
_isolationLevel = IsolationLevel.Serializable;
}
}
return _isolationLevel;
}
}
internal int ObjectID {
get {
return _objectID;
}
}
private void AssertNotCompleted() {
if (null == Connection || _connectionCloseCount != Connection.CloseCount) {
throw ADP.TransactionCompleted();
}
}
override public void Commit() {
OracleConnection.ExecutePermission.Demand();
IntPtr hscp;
Bid.ScopeEnter(out hscp, " %d#\n", ObjectID);
try {
AssertNotCompleted();
Connection.Commit();
Dispose(true);
}
finally {
Bid.ScopeLeave(ref hscp);
}
}
protected override void Dispose(bool disposing) {
if (disposing) {
if ( null != Connection ) {
Connection.Rollback();
}
_connection = null;
}
base.Dispose(disposing);
}
override public void Rollback() {
IntPtr hscp;
Bid.ScopeEnter(out hscp, " %d#\n", ObjectID);
try {
AssertNotCompleted();
Dispose(true);
}
finally {
Bid.ScopeLeave(ref hscp);
}
}
};
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
//-----------------------------------------------------------------------------
namespace System.Data.OracleClient
{
using System;
using System.Data;
using System.Data.Common;
using System.Runtime.InteropServices;
using System.Diagnostics;
//---------------------------------------------------------------------
// OracleTransaction
//
// Implements the Oracle Transaction object, which handles local
// transaction requests
//
sealed public class OracleTransaction : DbTransaction {
private OracleConnection _connection;
private int _connectionCloseCount; // The close count of the connection; used to decide if we're zombied
private IsolationLevel _isolationLevel = IsolationLevel.ReadCommitted;
private static int _objectTypeCount; // Bid counter
internal readonly int _objectID = System.Threading.Interlocked.Increment(ref _objectTypeCount);
internal OracleTransaction(OracleConnection connection) : this (connection, IsolationLevel.Unspecified) {}
internal OracleTransaction( OracleConnection connection, IsolationLevel isolationLevel ) {
OracleConnection.VerifyExecutePermission();
//-------------------------------------------------------------------------------------
// pre-condition validation
// ensure we are not attempting to nest transactions. Enforced at runtime by
// OracleInternalConnection.BeginOracleTransaction
Debug.Assert ( connection.TransactionState == TransactionState.AutoCommit );
// SQLHOTFIX# 50003423: setting isolation levels may require that we execute commands on
// the server which will, in turn, rollback any potentially dead transactions and reset
// our state to auto-commit mode. This typically happens when a connection is re-used
// to execute a new command after a previous command associated with a transaction
// has been committed. When we're attempting to begin a new transaction, we need to
// ensure that we've cleared the internal state *before* partially initializing members.
Debug.Assert ( connection.Transaction == null );
//--------------------------------------------------------------------------------------
TransactionState previousState = connection.TransactionState;
if (TransactionState.GlobalStarted == previousState) {
throw ADP.NoLocalTransactionInDistributedContext();
}
_connection = connection;
_connectionCloseCount = connection.CloseCount;
_isolationLevel = isolationLevel;
// SQLBUVSTS 39106: set the transaction state before changing the isolation level
_connection.TransactionState = TransactionState.LocalStarted;
try {
// Tell oracle what the isolation level should be.
switch (isolationLevel) {
case IsolationLevel.Unspecified:
// Take whatever we get from the server
break;
case IsolationLevel.ReadCommitted: {
// DEVNOTE: Most often, this is the default, but it is configurable on the server;
// we should avoid the roundtrip if we can figure out whether this is really
// the default.
using (OracleCommand cmd = Connection.CreateCommand()) {
cmd.CommandText = "set transaction isolation level read committed";
cmd.ExecuteNonQuery();
}
}
break;
case IsolationLevel.Serializable: {
using (OracleCommand cmd = Connection.CreateCommand()) {
cmd.CommandText = "set transaction isolation level serializable";
cmd.ExecuteNonQuery();
}
}
break;
default:
throw ADP.UnsupportedIsolationLevel();
}
}
catch {
// in case of error, revert the transaction state and rethrow
_connection.TransactionState = previousState;
throw;
}
// SQLBUDT# 449125 and SQLHOTFIX# 50003423 - ensure that connection's TransactionState has not been reset
// during initialization of the transaction object.
Debug.Assert(_connection.TransactionState == TransactionState.LocalStarted, "Executing commands to set isolational level has reset the connection's transaction state.");
}
new public OracleConnection Connection {
get {
return _connection;
}
}
override protected DbConnection DbConnection {
get {
return Connection;
}
}
override public IsolationLevel IsolationLevel {
get {
AssertNotCompleted();
if (IsolationLevel.Unspecified == _isolationLevel) {
using (OracleCommand cmd = Connection.CreateCommand()) {
cmd.Transaction = this;
cmd.CommandText = "select decode(value,'FALSE',0,1) from V$SYSTEM_PARAMETER where name = 'serializable'";
Decimal x = (Decimal)cmd.ExecuteScalar();
if (0 == x)
_isolationLevel = IsolationLevel.ReadCommitted;
else
_isolationLevel = IsolationLevel.Serializable;
}
}
return _isolationLevel;
}
}
internal int ObjectID {
get {
return _objectID;
}
}
private void AssertNotCompleted() {
if (null == Connection || _connectionCloseCount != Connection.CloseCount) {
throw ADP.TransactionCompleted();
}
}
override public void Commit() {
OracleConnection.ExecutePermission.Demand();
IntPtr hscp;
Bid.ScopeEnter(out hscp, " %d#\n", ObjectID);
try {
AssertNotCompleted();
Connection.Commit();
Dispose(true);
}
finally {
Bid.ScopeLeave(ref hscp);
}
}
protected override void Dispose(bool disposing) {
if (disposing) {
if ( null != Connection ) {
Connection.Rollback();
}
_connection = null;
}
base.Dispose(disposing);
}
override public void Rollback() {
IntPtr hscp;
Bid.ScopeEnter(out hscp, " %d#\n", ObjectID);
try {
AssertNotCompleted();
Dispose(true);
}
finally {
Bid.ScopeLeave(ref hscp);
}
}
};
}
// 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
- NamespaceList.cs
- StrokeNodeOperations.cs
- TabControl.cs
- Int32Rect.cs
- FieldNameLookup.cs
- FontStretchConverter.cs
- TargetParameterCountException.cs
- InstanceContextMode.cs
- WindowsFormsSynchronizationContext.cs
- QilStrConcat.cs
- XmlSchemaValidator.cs
- PathFigureCollection.cs
- PagerSettings.cs
- NamespaceMapping.cs
- PopupControlService.cs
- DataAdapter.cs
- _AutoWebProxyScriptWrapper.cs
- OrthographicCamera.cs
- UnsafeMethods.cs
- XAMLParseException.cs
- BlockCollection.cs
- TextBoxBase.cs
- WebPartDeleteVerb.cs
- MatchingStyle.cs
- SchemaHelper.cs
- PointConverter.cs
- RadialGradientBrush.cs
- NavigationProgressEventArgs.cs
- DynamicMethod.cs
- RegexParser.cs
- PropertySourceInfo.cs
- brushes.cs
- ObjectStateFormatter.cs
- PieceNameHelper.cs
- LinkTarget.cs
- ObjectDataSourceStatusEventArgs.cs
- WebServiceClientProxyGenerator.cs
- ReadOnlyCollectionBase.cs
- SkewTransform.cs
- CheckableControlBaseAdapter.cs
- PageThemeBuildProvider.cs
- FileDialog_Vista.cs
- Triplet.cs
- TextFormatterContext.cs
- HMACMD5.cs
- StateFinalizationDesigner.cs
- HttpDictionary.cs
- Hyperlink.cs
- PackUriHelper.cs
- QuaternionValueSerializer.cs
- FormsAuthenticationEventArgs.cs
- DependencyObjectProvider.cs
- DocumentPaginator.cs
- __Filters.cs
- HeaderUtility.cs
- DataGridViewButtonColumn.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- LinqDataView.cs
- LifetimeServices.cs
- Request.cs
- ValidatorCollection.cs
- MergeLocalizationDirectives.cs
- DataGridItem.cs
- DbReferenceCollection.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- CodeComment.cs
- DefaultSerializationProviderAttribute.cs
- StreamGeometry.cs
- SettingsPropertyWrongTypeException.cs
- TextSegment.cs
- HashMembershipCondition.cs
- Vector3D.cs
- ReturnType.cs
- __Error.cs
- PolicyLevel.cs
- Vector.cs
- securitycriticaldata.cs
- GridView.cs
- EnumConverter.cs
- TreeNodeBindingCollection.cs
- DataListGeneralPage.cs
- BrowserCapabilitiesCompiler.cs
- ConfigurationLoader.cs
- ExpressionBinding.cs
- ResourceProperty.cs
- TagMapInfo.cs
- XamlFigureLengthSerializer.cs
- Scheduling.cs
- NativeWindow.cs
- EncoderNLS.cs
- SqlGatherProducedAliases.cs
- RelationshipType.cs
- DataBoundLiteralControl.cs
- CommandBinding.cs
- WinEventWrap.cs
- FactoryGenerator.cs
- Debugger.cs
- QuaternionAnimation.cs
- QuaternionConverter.cs
- HostProtectionPermission.cs