CodeSmith Community
Your Code. Your Way. Faster!

Catch "RowUpdated" event and get at Rowstate old values like in Datasets and DataAdapters

Latest post 01-09-2007 1:39 PM by Robert Hinojosa. 5 replies.
  • 01-05-2007 2:04 PM

    Catch "RowUpdated" event and get at Rowstate old values like in Datasets and DataAdapters

    I was hoping someone could point me in the right direction. I'm normally used to working with DataAdapters and Datasets. Normally to implement business rules we would make heavy use of of the DataAdapter.RowUpdated event (for logging, notification etc...). What we really need is to be able to hook into events prior to and immediately after Save() events. Ideally we would want to do this in a fairly generic fashion.

    I noticed that after the Save() the state of the Entity gets changed, is there any way I can key into this change (is there an event I don't know about) without modifying the templates? Also, is there an easy way to get at old values of an entity. I was thinking of hooking into the PropertyChanged event and writing my own state tracking in the EntityBase, but I want to be sure there's not already something already there...

    Has anyone encountered these issues and if so, what solutions worked?

    Thanks in Advance,

    Tyler

    Filed under:
    • Post Points: 35
  • 01-08-2007 3:32 PM In reply to

    Re: Catch "RowUpdated" event and get at Rowstate old values like in Datasets and DataAdapters

    Hi,  if you want to monitor the entity itself, there's OnColumnChanged, OnPropertyChanged

    You can monitor a provider for Save, like:

    DataRepository.AddressProvider.DataRequested += new NameSpace.Data.Bases.EntityProviderBaseCore<Address, AddressKey>.DataRequestedEventHandler(AddressProvider_DataRequested);

           static void AddressProvider_DataRequested(object sender, NameSpace.Data.Bases.CommandEventArgs e)
           {
               if (e.MethodName == "Insert" || e.MethodName == "Update" || e.MethodName == "Delete")
               {
                     //do something
                     if (e.CurrentEntity != null)
                         Logger.Write(e.CurrentEntity.EntityTrackingKey);
               }
           }
               
     


    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 60
  • 01-08-2007 3:55 PM In reply to

    Re: Catch "RowUpdated" event and get at Rowstate old values like in Datasets and DataAdapters

    Awesome thanks Robert.
    • Post Points: 5
  • 01-08-2007 6:53 PM In reply to

    Re: Catch "RowUpdated" event and get at Rowstate old values like in Datasets and DataAdapters

    I think I spoke too soon. I can't seem to find this DataRequested event or any DataRequestedEventHandler delegates I did a search for similar strings as well and I couldn't find anything. I'm using the v2.0.0.387 templates.


    Also, is there an event that I can key into for ALL calls to the datarepository (regardless of which provider is being accessed) as opposed to wiring up every provider individually, or is the best way to do this to mod the templates so that all providers wire up to the event?

    Thanks in advance,

    Tyler

    • Post Points: 5
  • 01-09-2007 1:29 PM In reply to

    Re: Catch "RowUpdated" event and get at Rowstate old values like in Datasets and DataAdapters

    So no one knows of any events available under the v2.0.0.387 templates that allow you to detect CRUD actions against the data store?
    • Post Points: 35
  • 01-09-2007 1:39 PM In reply to

    Re: Catch "RowUpdated" event and get at Rowstate old values like in Datasets and DataAdapters

    Hi,

    I guess it was put it afterward, SVN Rev 411 is when it was introduced. You would have to do your own implementation if you wanted it with that version.  Since you are wanting to tap into everything, you can utilize the Utility.ExecuteNonQuery method and just wire up an event in there.  That will get called for every persisting call.  You could iterate through the params to get the values. 
     


    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 5
Page 1 of 1 (6 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems