Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 300643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:55:58+00:00 2026-05-12T06:55:58+00:00

I’m using the IPostUpdateEventListener interface to do update audit logging now, grabbing the old

  • 0

I’m using the IPostUpdateEventListener interface to do update audit logging now, grabbing the old and new values, then storing each updated field in an “Audit” table and all that jive. Works swell, but there’s two last requirements I’m having a hard time fullfilling:

  1. Display which employee the update was for.
  2. Display the “friendly” name of the field updated.

For #1, my first instinct was to use reflection and look for & grab the “Employee” property on the given entity to find out which Employee it was for, but that quickly falls apart when you’re a few objects deep in the graph with no automatic way to get back to the given Employee object.

Ideas to solve #1 ranged from requiring a “Parent” property on every object so I can traverse the graph looking for the Employee type (which, to me, would pollute our domain too much for a simple persistance concern) to using a separate SQL job to tranverse the foriegn keys and fill in the Employee ID after the fact (I’d rather not maintain a separate SQL job as everthing is code based thus far – and that SQL job will get quite nasty very quick).

As for the second requirement, I can get the actual property name that changed just fine. For a good 80% – 90% of our fields, the (properly formatted) property name is what we display, so I can just space the name based on the Pascal casing. The rest of the fields, however, don’t match up for various reasons. We’re using ASP.NET MVC and Fluent HTML builders from MvcContrib, but even if we modified the setup to the point of having an attribute on the view model that overridess what the field name should be (and therefor having it in code instead of just the view), there’s no real way to match those attributes from the view models to the domain objects being saved.

A final pragmatic solution to both problems would just be to call an audit logging service after each update operation in another service, passing in the field names and employee information as needed, but, well, I really don’t want to go there for obvious reasons.

Ideas for either problem would be greatly appreciated. Searching and racking my brain for a couple of days has turned up nothing of use – most people seem to stop at simple old/new vale recording or just a “created/updated” timestamp on the record itself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:55:59+00:00Added an answer on May 12, 2026 at 6:55 am

    I have a requirement similar to yours. In my case, it’s a health care application and the audit log needs to identify the patient to which the insert/update applies.

    My solution is to define an interface, which all audited classes need to implement :

    public interface IAuditedRecord
    {
        IPatient OwningPatient { get; }
    
        ...
        // Other audit-related properties (user, timestamp)
    }
    

    The audited classes then implement this interface in whatever way is required. For example:

    public class Medication : IAuditedRecord
    {
        // One end of a bidirectional association. Populated by NHibernate.
        private IPatient _patient;
    
        IPatient OwningPatient { get { return _patient; } }
    }
    
    public class MedicationNote : IAuditedRecord
    {
        // One end of a bidirectional association. Populated by NHibernate.
        private Medication _medication;
    
        IPatient OwningPatient { get { return _medication.OwningPatient; } }
    }
    

    The IPostInsertEventListener and IPostUpdateEventListener then fetch the OwningPatient property in order to populate the audit record.

    The solution has the advantages of keeping the auditing logic in the event listeners, which is the only place where one is sure that an insert/update will take place, as well as allowing the traversal of indirect links between an object and its owning patient.

    The downside is that the audited classes have to derive from a specific interface. I think the benefits outweigh this small cost.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 178k
  • Answers 178k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try running gacutil -l to check if the MSBuild assemblies… May 12, 2026 at 3:40 pm
  • Editorial Team
    Editorial Team added an answer The AdornerLayer is usually part of the default template of… May 12, 2026 at 3:40 pm
  • Editorial Team
    Editorial Team added an answer Use DATE() function: select * from follow_queue group by DATE(follow_date) May 12, 2026 at 3:40 pm

Related Questions

In order to apply a triggered animation to all ToolTip s in my app,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.