Created
August 18, 2015 08:44
-
-
Save masaru-b-cl/dda3a579ef3494d8b8d5 to your computer and use it in GitHub Desktop.
OracleDisenchanter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using System.Data.Common; | |
using Unmanaged = Oracle.DataAccess.Client; | |
using Managed = Oracle.ManagedDataAccess.Client; | |
namespace Continuo.Data.Oracle | |
{ | |
public class DisenchantedUnmanagedOracleCommand : DbCommand, IDbCommand, IDisposable | |
{ | |
private readonly Unmanaged.OracleCommand cmd; | |
public DisenchantedUnmanagedOracleCommand(Unmanaged.OracleCommand cmd) | |
{ | |
this.cmd = cmd; | |
} | |
public override string CommandText | |
{ | |
get | |
{ | |
return this.cmd.CommandText; | |
} | |
set | |
{ | |
this.cmd.CommandText = value; | |
} | |
} | |
public override int CommandTimeout | |
{ | |
get | |
{ | |
return this.cmd.CommandTimeout; | |
} | |
set | |
{ | |
this.cmd.CommandTimeout = value; | |
} | |
} | |
public override CommandType CommandType | |
{ | |
get | |
{ | |
return this.cmd.CommandType; | |
} | |
set | |
{ | |
this.cmd.CommandType = value; | |
} | |
} | |
public override bool DesignTimeVisible | |
{ | |
get | |
{ | |
return this.cmd.DesignTimeVisible; | |
} | |
set | |
{ | |
this.cmd.DesignTimeVisible = value; | |
} | |
} | |
public override UpdateRowSource UpdatedRowSource | |
{ | |
get | |
{ | |
return this.cmd.UpdatedRowSource; | |
} | |
set | |
{ | |
this.cmd.UpdatedRowSource = value; | |
} | |
} | |
protected override DbConnection DbConnection | |
{ | |
get | |
{ | |
return this.cmd.Connection; | |
} | |
set | |
{ | |
this.cmd.Connection = (Unmanaged.OracleConnection)value; | |
} | |
} | |
protected override DbParameterCollection DbParameterCollection | |
{ | |
get | |
{ | |
return this.cmd.Parameters; | |
} | |
} | |
protected override DbTransaction DbTransaction | |
{ | |
get | |
{ | |
return this.cmd.Transaction; | |
} | |
set | |
{ | |
this.cmd.Transaction = (Unmanaged.OracleTransaction)value; | |
} | |
} | |
public override void Cancel() | |
{ | |
this.cmd.Cancel(); | |
} | |
public override int ExecuteNonQuery() | |
{ | |
return this.cmd.ExecuteNonQuery(); | |
} | |
public override object ExecuteScalar() | |
{ | |
return this.cmd.ExecuteScalar(); | |
} | |
public override void Prepare() | |
{ | |
this.cmd.Prepare(); | |
} | |
protected override DbParameter CreateDbParameter() | |
{ | |
return this.cmd.CreateParameter(); | |
} | |
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) | |
{ | |
return this.cmd.ExecuteReader(behavior); | |
} | |
#region IDisposable Support | |
private bool disposedValue = false; | |
protected override void Dispose(bool disposing) | |
{ | |
if (!disposedValue) | |
{ | |
if (disposing) | |
{ | |
foreach (Unmanaged.OracleParameter param in this.cmd.Parameters) | |
{ | |
param.Dispose(); | |
} | |
this.cmd.Dispose(); | |
} | |
disposedValue = true; | |
} | |
} | |
#endregion | |
} | |
public class DisenchantedManagedOracleCommand : DbCommand, IDbCommand, IDisposable | |
{ | |
private readonly Managed.OracleCommand cmd; | |
public DisenchantedManagedOracleCommand(Managed.OracleCommand cmd) | |
{ | |
this.cmd = cmd; | |
} | |
public override string CommandText | |
{ | |
get | |
{ | |
return this.cmd.CommandText; | |
} | |
set | |
{ | |
this.cmd.CommandText = value; | |
} | |
} | |
public override int CommandTimeout | |
{ | |
get | |
{ | |
return this.cmd.CommandTimeout; | |
} | |
set | |
{ | |
this.cmd.CommandTimeout = value; | |
} | |
} | |
public override CommandType CommandType | |
{ | |
get | |
{ | |
return this.cmd.CommandType; | |
} | |
set | |
{ | |
this.cmd.CommandType = value; | |
} | |
} | |
public override bool DesignTimeVisible | |
{ | |
get | |
{ | |
return this.cmd.DesignTimeVisible; | |
} | |
set | |
{ | |
this.cmd.DesignTimeVisible = value; | |
} | |
} | |
public override UpdateRowSource UpdatedRowSource | |
{ | |
get | |
{ | |
return this.cmd.UpdatedRowSource; | |
} | |
set | |
{ | |
this.cmd.UpdatedRowSource = value; | |
} | |
} | |
protected override DbConnection DbConnection | |
{ | |
get | |
{ | |
return this.cmd.Connection; | |
} | |
set | |
{ | |
this.cmd.Connection = (Managed.OracleConnection)value; | |
} | |
} | |
protected override DbParameterCollection DbParameterCollection | |
{ | |
get | |
{ | |
return this.cmd.Parameters; | |
} | |
} | |
protected override DbTransaction DbTransaction | |
{ | |
get | |
{ | |
return this.cmd.Transaction; | |
} | |
set | |
{ | |
this.cmd.Transaction = (Managed.OracleTransaction)value; | |
} | |
} | |
public override void Cancel() | |
{ | |
this.cmd.Cancel(); | |
} | |
public override int ExecuteNonQuery() | |
{ | |
return this.cmd.ExecuteNonQuery(); | |
} | |
public override object ExecuteScalar() | |
{ | |
return this.cmd.ExecuteScalar(); | |
} | |
public override void Prepare() | |
{ | |
this.cmd.Prepare(); | |
} | |
protected override DbParameter CreateDbParameter() | |
{ | |
return this.cmd.CreateParameter(); | |
} | |
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) | |
{ | |
return this.cmd.ExecuteReader(behavior); | |
} | |
#region IDisposable Support | |
private bool disposedValue = false; | |
protected override void Dispose(bool disposing) | |
{ | |
if (!disposedValue) | |
{ | |
if (disposing) | |
{ | |
foreach (Managed.OracleParameter param in this.cmd.Parameters) | |
{ | |
param.Dispose(); | |
} | |
this.cmd.Dispose(); | |
} | |
disposedValue = true; | |
} | |
} | |
#endregion | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using System.Data.Common; | |
using Unmanaged = Oracle.DataAccess.Client; | |
using Managed = Oracle.ManagedDataAccess.Client; | |
namespace Continuo.Data.Oracle | |
{ | |
public class DisenchantedUnmanagedOracleConnection : DbConnection, IDbConnection, IDisposable | |
{ | |
private readonly Unmanaged.OracleConnection conn; | |
public DisenchantedUnmanagedOracleConnection(Unmanaged.OracleConnection conn) | |
{ | |
this.conn = conn; | |
} | |
public override string ConnectionString | |
{ | |
get | |
{ | |
return this.conn.ConnectionString; | |
} | |
set | |
{ | |
this.conn.ConnectionString = value; | |
} | |
} | |
public override string Database | |
{ | |
get | |
{ | |
return this.conn.Database; | |
} | |
} | |
public override string DataSource | |
{ | |
get | |
{ | |
return this.conn.DataSource; | |
} | |
} | |
public override string ServerVersion | |
{ | |
get | |
{ | |
return this.conn.ServerVersion; | |
} | |
} | |
public override ConnectionState State | |
{ | |
get | |
{ | |
return this.conn.State; | |
} | |
} | |
public override void ChangeDatabase(string databaseName) | |
{ | |
this.conn.ChangeDatabase(databaseName); | |
} | |
public override void Close() | |
{ | |
this.conn.Close(); | |
} | |
public override void Open() | |
{ | |
this.conn.Open(); | |
} | |
protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) | |
{ | |
return this.conn.BeginTransaction(isolationLevel); | |
} | |
protected override DbCommand CreateDbCommand() | |
{ | |
return new DisenchantedUnmanagedOracleCommand(this.conn.CreateCommand()); | |
} | |
} | |
public class DisenchantedManagedOracleConnection : DbConnection, IDbConnection, IDisposable | |
{ | |
private readonly Managed.OracleConnection conn; | |
public DisenchantedManagedOracleConnection(Managed.OracleConnection conn) | |
{ | |
this.conn = conn; | |
} | |
public override string ConnectionString | |
{ | |
get | |
{ | |
return this.conn.ConnectionString; | |
} | |
set | |
{ | |
this.conn.ConnectionString = value; | |
} | |
} | |
public override string Database | |
{ | |
get | |
{ | |
return this.conn.Database; | |
} | |
} | |
public override string DataSource | |
{ | |
get | |
{ | |
return this.conn.DataSource; | |
} | |
} | |
public override string ServerVersion | |
{ | |
get | |
{ | |
return this.conn.ServerVersion; | |
} | |
} | |
public override ConnectionState State | |
{ | |
get | |
{ | |
return this.conn.State; | |
} | |
} | |
public override void ChangeDatabase(string databaseName) | |
{ | |
this.conn.ChangeDatabase(databaseName); | |
} | |
public override void Close() | |
{ | |
this.conn.Close(); | |
} | |
public override void Open() | |
{ | |
this.conn.Open(); | |
} | |
protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) | |
{ | |
return this.conn.BeginTransaction(isolationLevel); | |
} | |
protected override DbCommand CreateDbCommand() | |
{ | |
return new DisenchantedManagedOracleCommand(this.conn.CreateCommand()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment