SaveChanges And Functionality

Thread is closed for posting
2 posts, 0 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 05 Apr 2012 Link to this post


    I was just curious if the process of saving changes to the database via Context.SaveChanges() was similar to EF, which can be a huge black hole when an error occurs (since it doesn't tell you which entity received an error, and only commits some of the changes unless a transaction was used).  Does OpenAccess work the same way, where you call SaveChanges, and it tries to push up all the objects, and you may or may not get an error?  Or does it open up what's going on within the submitted entities to let you know which object caused an error.

    I understand transactions exist to prevent that partial update, and I'm in full agreement, however I was wondering if there were ways to tap into it anyway.

  2. Zoran
    Zoran avatar
    534 posts

    Posted 10 Apr 2012 Link to this post

    Hi Brian,

     With OpenAccess, the changes are always committed inside a transaction. Even if you do not create one, OpenAccess starts a transaction when you call SaveChanges() and either all changes are written in the database or none of them. The changes that are committed within that transaction are the changes made after your last SaveChanges() call or after your context initialization in the case this is your first SaveChanges() call with that context.

    Even though there is no way you can push only partial changes to the database, the exceptions that can arise during a SaveChanges() call are countless. In the case the exception is thrown from the SQL Server, that is the exception propagated to the user. It usually contains the SQL Statement that caused the exception if there is one. Having the SQL statement that caused the exception, should give you some valuable information when you debug problems of this kind.

    There are also number of exception that contain information about the entity that caused the exception, and the SqlException is passed as an inner exception. Not all exceptions are caused by a specific entity, but we always try to give as much as valuable information as possible so we make the life of the debugging developer easier with our product. We will appreciate any feedback for any exception that you find which is not giving enough information o is misleading in your opinion.

    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Back to Top