2

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 ;)

4

1 回答 1

3

在实际生成任何内容之前,CodeFluent Entities 会解析模型并将其转换为包含实体、属性、方法、表、列、过程等的完整内存表示。执行此转换的推理引擎使用分为多个步骤的管道. CodeFluent Entities Aspects 可以在任何步骤中引入,并且能够修改当前内存中的模型,从而影响后续步骤。如何写一个方面太长了,无法在 SO 上解释。

您可以在以下网址找到我的完整答案: http: //blog.codefluententities.com/2013/09/25/writing-a-custom-codefluent-entities-aspect-to-encrypt-decrypt-columns-values-at-runtime /

于 2013-09-25T14:03:26.013 回答