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

SaveChanges And Functionality

1 Answer 61 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brian Mains
Top achievements
Rank 1
Brian Mains asked on 05 Apr 2012, 09:07 PM
Hello,

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.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 10 Apr 2012, 04:40 PM
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.

Greetings,
Zoran
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Tags
General Discussions
Asked by
Brian Mains
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Share this question
or