New Posts New Posts RSS Feed: Concurrency handling and EntitiesWithErrors is null
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Concurrency handling and EntitiesWithErrors is null

 Post Reply Post Reply
Author
sebma View Drop Down
Groupie
Groupie
Avatar

Joined: 19-Aug-2008
Location: Singapore
Posts: 66
Post Options Post Options   Quote sebma Quote  Post ReplyReply Direct Link To This Post Topic: Concurrency handling and EntitiesWithErrors is null
    Posted: 22-Sep-2008 at 2:20am
I followed the learning units on handling concurrency and having an AutoIncrement RowVersion columns and BaseEntity etc., and it works. A EntityManagerSaveException is now thrown when there is a concurrency conflict.

However, I do not know why the inner exception's EntitiesWithErrors is always null, as in the TODO codes below :-(

      public static ConflictScenario HandleConcurrencyException(DomainModelEntityManager pEntityManager, EntityManagerSaveException pException, ConcurrencyResolutionStyle pResolutionStyle)
      {

          StringBuilder msg = new StringBuilder();

          if (pResolutionStyle == ConcurrencyResolutionStyle.JustReportTheViolation)
          {
              Console.WriteLine("A concurrency error occurred while saving your data." + "\n" + "\n" + " Someone probably saved their changes while you were making your changes." + "\n" + "\n");
              return ConflictScenario.NotDiscriminated;
          }
          else
          {
          // TODO: pException.EntitiesWithErrors is null
          //    Entity entityWithError = pException.EntitiesWithErrors[0];
          //    switch (pResolutionStyle)
          //    {
          //        case ConcurrencyResolutionStyle.DatabaseVersionWins:
          //            return KeepDatabaseChanges(pEntityManager, entityWithError);
          //        case ConcurrencyResolutionStyle.LocalVersionWins:
          //            return KeepMyChanges(pEntityManager, entityWithError);
          //        case ConcurrencyResolutionStyle.ResolveConflicts:
          //            return ResolveMyConflicts(pEntityManager, entityWithError);
          //        default:
                      return ConflictScenario.NotDiscriminated;
          //    }
          }
      }


Thanks and best regards
-Sebastian
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 23-Sep-2008 at 2:01pm
Looking into this...back soon.
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 24-Sep-2008 at 5:45pm
Sebastian:
 
Using the current release version of DevForce EF (4.2.0) and the concurrency tutorial from that, I am unable to reproduce your problem. My pException.EntitiesWithErrors[0] contains the entity involved in the conflict.
 
I notice that your code is a bit different from that in the concurrency learning unit that accompanies the 4.2.0 release. Where did it come from?
 
Greg Dunn
 
Back to Top
sebma View Drop Down
Groupie
Groupie
Avatar

Joined: 19-Aug-2008
Location: Singapore
Posts: 66
Post Options Post Options   Quote sebma Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2008 at 8:32am
Hi Greg,

I zipped my associated files in attachment, not sure if they make any sense without the complete VS solution.

I was merely duplicating the codes from "Program Files\IdeaBlade DevForce EF\Learning Units\200 Intermediate\030 Handling Concurrency Conflicts\02 Code CSharp\Completed Solution".

Thanks
-SebastianConcurrency_Files.zip
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2008 at 2:58pm
Sebastian, I did the following:
 
1. Took your version of ConcurrencyHandler.cs and plopped it into the Completed Solution from the concurrency Learning Unit in the product release;
2. Changed the namespace back to "UI";
3. Compiled the app successfully;
4. Set a breakpoint just inside the HandleConcurrencyException() method;
5. Ran two copies of the app (one by double-clicking the UI.exe executable);
6. Opened the Employee tab in both instances of the app to load the Employee data;
7. Changed Nancy Davolio's first name in the instance run by double-clicking UI.exe, and saved the change;
8. Changed Nancy's first name in the instance launched from inside Visual Studio, and attempted to save that, resulting in a concurrency exception;
9. At the breakpoint in HandleConcurrencyException, examined pException.EntitiesWithErrors[0] and found Nancy Davolio there.
 
So, I am unable to reproduce the problem.
 
Can you do the steps above with the *unchanged* Completed Solution with the Learning Unit and tell me if you get a different result?
 
Thanks,
Greg
 
Back to Top
sebma View Drop Down
Groupie
Groupie
Avatar

Joined: 19-Aug-2008
Location: Singapore
Posts: 66
Post Options Post Options   Quote sebma Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2008 at 11:42pm
Sure Greg, I shall do this over the weekend ;-)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down