Repository & Tracking Changes

Thread is closed for posting
4 posts, 0 answers
  1. Jean-Yves
    Jean-Yves avatar
    69 posts
    Member since:
    Feb 2009

    Posted 02 Oct 2011 Link to this post


    I would like to know if you have a 'best practice' to implement a repository with an integrated tranking changes.

    Some thing like : each time I Insert, Update or Delete, this baseRepository will write in the databases the changes...

    Could you help me? 

    Thank you
  2. Serge
    Serge avatar
    375 posts

    Posted 05 Oct 2011 Link to this post

    Hi Jean-Yves,

     The term best practice usually depends greatly on the problem and situation. There are a couple of ways you could achieve this behaviour. 

    First of all, do you want all changes made to objects to be tracked, or is it just the changes that are applied to the database. If it is the latter the context class provides an API that you can use to have a look at the changes that will be persisted just before calling SaveChanges(). You can use context.GetChanges for this (for a more comprehensive explanation have a look at this article).

    You could easily wrap all SaveOperations in a UnitOfWork pattern where you could perform the needed logging. Actually doing separate repositories for each entity that do not have a save changes method and a unit of work implementation (for saving changes) is something that we are working on for one of our best practice examples, that will be revamped for Q3. 

    It will not be a problem to provide a sneak peek of what we are thinking of in a demo, should you request it (please open a support ticket if you do).

    I hope this helps.

    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

  3. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 23 Nov 2011 Link to this post

    As long as you don't want field level changes...
    If all you are looking for is a "count" of the changes (ha ha), you are good... anything else...forget it.

    If you want a comedy to read in your spare time regarding my begging and pleading on the subject... read this POST.

  4. Serge
    Serge avatar
    375 posts

    Posted 28 Nov 2011 Link to this post

    Hello Jean-Yves,

     I am writing to notify you that we have updated the SDK that is available on our site with the Q3 release and you can now download it and have a look at Sofia Car Rental best practices series of examples in it, that feature a full blown DTO layer, Repository and UnitOfWork patterns.

    the Telerik team

    Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Back to Top