Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

When implementing IDbCommandInterceptor, I can get access to the SQL command that has been created for the command/query. Is it also possible to get access to the actual entity object that is being persisted/retrieved whilst in the implemented methods?

Here is some fantasy code to demonstrate what I would like to do:

public class WidgetInterceptor : IDbCommandInterceptor
{
    public void NonQueryExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
    {
        var widget = interceptionContext.Entity as Widget;

        if(widget != null)
        {
            //Perform tasks on widget before it is saved...
        }
    }
}
share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.