Pregunta

I'm using CodeFluent Entities to manage my database for a ASPNET MVC3 web application. I would like to find a way to configure a Property of an Entity in my Model which would be 'transparently' managed with EncryptByPassPhrase and DecryptByPassPhrase TSQL functions.

Example TSQL INSERT/UPDATE (property 'Text') :

-> Add a @PassPhrase(?) parameter to send my key string -> replace '@Text' by 'EncryptByPassPhrase(@PassPhrase,@Text)

Example TSQL LOAD/SEARCH (property 'Text') :

-> Add a @PassPhrase(?) parameter to send my key string -> replace '@Text' by 'DecryptByPassPhrase(@PassPhrase,@Text)

Basically, I want to save an encrypted data (from a clear text) and retrieve a decrypted data (from the encrypted field value), without writing stored procedure on my own.

I know I can solve my problem it by creating a custom SQL Stored Procedure for both Save() and Load*() methods, but it seems to me that a tool like CodeFluent Entities might provide a way to feed my needs.

Thanks to anyone that can help me on that ;)

¿Fue útil?

Solución

Before anything is actually generated, CodeFluent Entities parses the model and transforms it into a complete memory representation which contains Entities, Properties, Methods, Tables, Columns, Procedures, etc. The inference engine that does this transformation is using a pipeline that’s divided into steps. CodeFluent Entities Aspects can be introduced at any step, and are able to modify the model currently in memory, therefore influencing the next steps. How to write an aspect is too long to be explained on SO.

You’ll find my complete answer at: http://blog.codefluententities.com/2013/09/25/writing-a-custom-codefluent-entities-aspect-to-encrypt-decrypt-columns-values-at-runtime/

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top