Automatically update audit information on Entity

Posted by Nix on Stack Overflow See other posts from Stack Overflow or by Nix
Published on 2010-04-06T21:39:40Z Indexed on 2010/04/06 21:43 UTC
Read the original article Hit count: 210

Filed under:
|
|

I have an entity model that has audit information on every table (50+ tables)

 CreateDate
 CreateUser
 UpdateDate
 UpdateUser

Currently we are programatically updating audit information.

Ex:

  if(changed){
        entity.UpdatedOn = DateTime.Now;
        entity.UpdatedBy = Environment.UserName;
        context.SaveChanges();
   }

But I am looking for a more automated solution. During save changes, if an entity is created/updated I would like to automatically update these fields before sending them to the database for storage.

Any suggestion on how i could do this?

Let me know if any more information is needed.

© Stack Overflow or respective owner

Related posts about .net-3.5

Related posts about entity-framework