This is a migrated thread and some comments may be shown as answers.

Repository & Tracking Changes

3 Answers 131 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jean-Yves
Top achievements
Rank 1
Jean-Yves asked on 02 Oct 2011, 06:51 PM
Hello, 

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

3 Answers, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 05 Oct 2011, 04:19 PM
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.

Regards,
Serge
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 >>

0
Shawn Krivjansky
Top achievements
Rank 1
answered on 24 Nov 2011, 01:19 AM
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.


0
Serge
Telerik team
answered on 28 Nov 2011, 01:06 PM
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.

Greetings,
Serge
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!

Tags
Getting Started
Asked by
Jean-Yves
Top achievements
Rank 1
Answers by
Serge
Telerik team
Shawn Krivjansky
Top achievements
Rank 1
Share this question
or