I understand the inconvenience on your side, and I am sorry about it.
To achieve the necessary result, you need to re-add the product
object to the context in the catch
clause like this:
//Re-adding the product object to the context
This is required, because when the SaveChanges() call in the try
clause failed, the transaction that held the insert operation was rolled back
, and in-memory Telerik Data Access restored the state of the product
object to its previous one (more information about the object states is available here
). This is the reason why you see the loss of the changes (without any log about it) before the call to the Refresh() method.
Regarding Refresh(), it does not provide you with the expected result in this case, because the performed changes are already overwritten when the transaction failed. It simply issues a query to the database that should load in-memory the data for the product
Additionally, it would very appreciated, if you could provide us with the link to the documentation article, that mislead you during the implementation.
I hope this helps. I am looking forward to your feedback.
OpenAccess ORM is now Telerik Data Access
. For more information on the new names, please, check out the Telerik Product Map