OracleConnection.ClientId?
Posted: Tue 16 Feb 2010 16:39
My entity framework ObjectContext partial looks like below. I have a need that for every new oracle connection DevArt makes to get the ClientId property set (different than User Id which is our app account). We use an app user account and we need to continue passing in the actual user as client id so we can extract it on the DB side in our triggers for CreatedBy / EditedBy audit fields to get the real end user.
The problem is Devart.Data.Oracle.OracleConnection does not expose a ClientId property like Oracle.DataAccess.Client.OracleConnection does. How can I accomplish this with Devart? This is essential for our auditing.
The problem is Devart.Data.Oracle.OracleConnection does not expose a ClientId property like Oracle.DataAccess.Client.OracleConnection does. How can I accomplish this with Devart? This is essential for our auditing.
Code: Select all
// This file is intended to be edited manually
using System.Data;
using System.Data.EntityClient;
using System.Diagnostics;
using System.Security.Principal;
using Devart.Data.Oracle;
namespace TWData
{
partial class TWDataEntities : ITWDataEntities
{
// Place your implementation of partial extension methods here
partial void OnContextCreated()
{
if (null == this.Connection) return;
this.Connection.StateChange += Connection_StateChange;
}
private EntityConnection EntityConnection
{
[DebuggerStepThrough]
get { return this.Connection as EntityConnection; }
}
private OracleConnection OracleConnection
{
[DebuggerStepThrough]
get { return this.EntityConnection.StoreConnection as OracleConnection; }
}
private void Connection_StateChange(object sender, StateChangeEventArgs e)
{
Debug.WriteLine(e.CurrentState.ToString());
//if (e.CurrentState != ConnectionState.Connecting) return;
if (e.CurrentState != ConnectionState.Open) return;
Debug.WriteLine(this.Connection.ConnectionString);
var oracleConn = this.OracleConnection;
if (null == oracleConn) return;
//var user = new WindowsPrincipal(WindowsIdentity.GetCurrent());
//var clientId = user.Identity.Name;
//oracleConn.ConnectionString += ""
//oracleConn.ConnectionString
// there is no ClientId on OracleConnection b/c it is Devart.OracleConnection not OracleConnection
//oracleConn.ClientId
return;
}
protected override void Dispose(bool disposing)
{
if (null != this.Connection)
this.Connection.StateChange -= Connection_StateChange;
base.Dispose(disposing);
}
}
}