sql server 2008 r2 - Right after establishing a new connection to a DB need to execute a specific TSQL command. All is under EF5.0 (Model First) -


using entity framework 5.0, , ms sql server 2012. implementing cell level encryption functionality. requires specific set of actions encrypt/decrypt data:

  1. open encryption key (ex. executing open symmetric key tsql command)
  2. execute following select decryptbykey(key_guid, encrypteddate) sometable

the question is: how, under entity framework 5.0 can run open key command right after new connection db established? after key opened, stay open until db session active.

thank you

maybe can subscribe connection's statechange event:

this.database.connection.statechange += this.connection_statechange; // "this" dbcontext.  private void connection_statechange(object sender, statechangeeventargs e) {     if(e.currentstate == connectionstate.open)     {         // commands here using sender sqlconnection.     } } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -