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

No entries in GetLastConflicts during OptimisticVerificationException

3 Answers 34 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.
Florian
Top achievements
Rank 1
Florian asked on 28 Jul 2015, 04:03 PM

Hi there

I try to resolve an OptimisticVerificationException: The user1 changes data of an entity but does not commit it to the database yet. Another user2 changes data on the database. Now the user1 tries to commit the data and retrieves an OptimisticVerificationException. This is expected. But now I try to resolve the entity which caused the conflict by using the GetLastConflicts method on the context. But there are no entries returned (even if ConcurrencyConflictsProcessingMode 
is AggregateAll). Is this a known bug? I can get the object-Id by, but as I don't have the object-type, I cannot get the conflicting object.

 

catch (OptimisticVerificationException ex)
{
   IList<ConcurrencyConflict> conflicts = this.GetLastConflicts(); // always Count == 0

 ​

I'm using DataAccess 2015.1.225.1.

Greetings,

Florian

 

3 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 31 Jul 2015, 01:54 PM
Hi Florian,

 Yes, this is a known bug.
You can work around the issue by getting the inner exceptions of the OptimisticVerificationException.
01.catch(Telerik.OpenAccess.Exceptions.OptimisticVerificationException ex)
02.{
03.    var optimisticVerificationExceptions = ex.InnerExceptions.Where(x => x.GetType() == typeof(OptimisticVerificationException));
04.    foreach(var innerEx in optimisticVerificationExceptions)  
05.    {
06.        var failedObjectId = innerEx.FailedObject;
07.        context.Refresh(Telerik.OpenAccess.RefreshMode.OverwriteChangesFromStore, failedObjectId)
08.    }      
09.}

 The Refresh call will update the in-memory object with latest values from the database.

Do get back in case you need further assistance.

Regards,
Ady
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
0
Martijn
Top achievements
Rank 1
answered on 27 Jun 2016, 12:59 PM

Hi Ady,

This is still a problem in the newest DataAccess (2016.1.224.1) version, when are you going to solve this?

Also with this workaround the amount of exceptions are incorrect, always returning 1 exception while I have e.g. 2 conflicts.

 

Greetings,


Martijn

 

0
Ady
Telerik team
answered on 04 Jul 2016, 11:11 AM
Hello Martijn,

 Given the availability of a workaround, there are no immediate plans to fix this bug for the next official release and hence I cannot commit to a fixed timeframe for the fix.

Regarding getting only 1 exception when there more conflicts - DataAccess executes the update query for each object and fails when the first update cannot be done. Even if there are more conflicts there is not point in trying to execute the rest after the first conflict is encountered.

Hope this answers your questions.


Regards,
Ady
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
General Discussions
Asked by
Florian
Top achievements
Rank 1
Answers by
Ady
Telerik team
Martijn
Top achievements
Rank 1
Share this question
or