Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the connection is a partial class you can implement a trigger that sets the client id whenever the connection changes state to open. That's the way I implemented it.</p> <p>I don't know if you can use part of this:</p> <pre><code>public partial class DataContext { partial void OnContextCreated() { if ( null == this.Connection ) return; this.Connection.StateChange += Connection_StateChange; } private EntityConnection EntityConnection { get { return this.Connection as EntityConnection; } } private OracleConnection OracleConnection { get { return this.EntityConnection.StoreConnection as OracleConnection; } } private void Connection_StateChange( object sender, StateChangeEventArgs e ) { if ( e.CurrentState != ConnectionState.Open ) return; OracleConnection conn = this.OracleConnection; if ( null == conn ) return; //closes connection on DataContext (bug?), and passes closed/broken connection //conn.ClientId = HttpContext.Current == null ? "Anonymous" : HttpContext.Current.Profile.UserName; //working solution string identity = HttpContext.Current == null ? "Anonymous" : HttpContext.Current.Profile.UserName; OracleCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DBMS_SESSION.SET_IDENTIFIER"; cmd.Parameters.Add( new OracleParameter { ParameterName = "client_id", Value = identity } ); cmd.ExecuteNonQuery(); cmd.Dispose(); return; } protected override void Dispose( bool disposing ) { if ( null != this.Connection ) this.Connection.StateChange -= Connection_StateChange; base.Dispose( disposing ); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload