Telerik OpenAccess ORM offers the GetChanges()
method of the OpenAccessContext
class that can help you in this case. It basically retrieves all the changes that will be persisted during the next commit to an instance of the Telerik.OpenAccess.ContextChanges
class and from there you can analyze them with the help of the GetInserts<T>()
is an article that provides an example).
Regarding the case provided by your code snippet, I would suggest to you the following:
(EntitiesModel dbContext =
Telerik.OpenAccess.ContextChanges changes = dbContext.GetChanges();
IEnumerable<Journal> uncommittedJurnals = changes.GetInserts<Journal>();
//do the processing here
You could also combine all the changes related to a given persistent type like this:
IEnumerable<Journal> uncommittedJurnals = changes.GetInserts<Journal>()
Note that OpenAccess ORM offers the so called persistence by reachability that allows you persist a graph of related objects to the database. You take advantage of it in the cases when you create two new object, relate them through the navigation properties and add just one of them to the Add() method of the context. In such scenarios both objects will be persisted to the database but only the one added to the context will be detected as a change by the GetChanges() method. To avoid that you need to take advantage of the IsManaged property of the navigation properties (this section
of our documentation will give you additional information).
I hope this helps. If you need further assistance or have other questions, do not hesitate to get back to us.
OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features
shipped with our latest release!