0

I have some code which encrypts and decrypts data using EF POCO. To implement this I intercepted the Saving Changes and ObjectMaterialized events and it works (most of the time).

The issue I have is if I try to read back the encrypted object straight after saving the object the materialized event does'nt fire as it not going back to the DB to retrieve the record and therefore fails to fire the event.

Does anyone have any thoughts on how I could improve my approach to cover off this situation ?

John Kattenhorn
  • 839
  • 11
  • 25
  • Probably I don't understand, but why do you want to read back what you just saved? Did you try to detach the object and then reread? – Gert Arnold Nov 19 '12 at 21:49
  • Sorry I was'nt clear enough the save of the object is done in one method and the retrieve happens in another. – John Kattenhorn Nov 20 '12 at 16:17
  • OK, and apparently with the same context. But did you try to detach the object and then reread? – Gert Arnold Nov 20 '12 at 17:40
  • Yep and it works of sorts; but then I run into issues with the ObjectStateManager when I try to re-attach the object to update it. I'm pretty sure I was be shorting the lifespan of the context; I'm using StructureMap to supply the Context to my repositories and this is a Console App so I'm looking at this at the moment. – John Kattenhorn Nov 21 '12 at 08:25

0 Answers0