New Posts New Posts RSS Feed: Another ImportEntities bug?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Another ImportEntities bug?

 Post Reply Post Reply
Author
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Topic: Another ImportEntities bug?
    Posted: 17-Sep-2010 at 10:16am
MainEntityManager has a bunch of Entities. Change one of them, then import that newly changed Entity into TempEntityManager. Save with TempEntityManager. In the SaveCallback (the Entity says its Unchanged and has no value for OriginalValuesMap) go ahead and import the resultant entity back into MainEntityManager. Now look at this entity in MainEntityManager...
 
It has EntityState of Unchanged but it has OriginalValuesMap with data in it. So if you call RejectChanges it goes back to the original value from BEFORE the save. I do not think this is correct. Even if you call AcceptChanges after you import it does nothing and when you call RejectChanges it will revert to the wrong value from BEFORE the save. Currently to work around this I call RejectChanges BEFORE I import the newly saved Entity in MainEntityManager - this puts the OriginalValuesMap to null, then when you import its all good and RejectChanges works as expected.
 
It seems very wrong to me that you can have an Unchanged state yet have original values that differ from the current values.


Edited by midnit - 17-Sep-2010 at 10:17am
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 30-Sep-2010 at 6:12am

Am I to assume due to lack of response that no one at IdeaBlade cares?

Wasted my time, but thank you for yours.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 30-Sep-2010 at 5:12pm
Hi,
 
I could not reproduce your issue. Can you provide a reproducible test case?
 
By the way, below is the test I ran (against northwindIB):
 
  int employeeID = 1;
  var targetedEmployeesList = _em1.Employees
    .Where(emp => emp.EmployeeID == employeeID)
    .ToList();
  Employee anEmployee = targetedEmployeesList.First();
  anEmployee.FirstName = ModifyString(anEmployee.FirstName);
  _em2.ImportEntities(new Entity[] { anEmployee }, MergeStrategy.OverwriteChanges);
  var op2 = _em2.SaveChangesAsync();
  op2.Completed += (s, savedArgs) => {
    _em1.ImportEntities(savedArgs.Entities, MergeStrategy.OverwriteChanges);
    var myEmployeeBackToEM1 = _em1.Employees.With(QueryStrategy.CacheOnly).First();
    var nameBeforeRejectChanges = myEmployeeBackToEM1.FirstName;
    _em1.RejectChanges();
    var nameAfterRejectChanges = myEmployeeBackToEM1.FirstName;
    if (nameBeforeRejectChanges == nameAfterRejectChanges) {
      MessageBox.Show("Same values before and after RejectChanges");
    } else {
      MessageBox.Show("Values changed !");
    }
  };
 
 
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 04-Oct-2010 at 6:34am
To be honest that was over 2 weeks ago and I have moved far beyond this issue since we have a "workaround" in place. We do not have sql server of any form or northwind and the effort to locate, install, configure these and create an application that reproduces the problem is SO far outside my available time its not funny.
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 04-Oct-2010 at 6:59am
But despite the inability to reproduce the specific issue, why would the entity be able to be "Unchanged" but have original data, and if you rejectchanges on an entity that looked like that it recovers the original data...even though its in an "Unchanged" state. It seems something in the process of setting state, or somewhere, it should prevent the possibility of this mixed up circumstance to exist.
 
Is there a case where your object should says its "Unchanged" but have OriginalMappedValues? And those values are different then the entities current values? That does not match my idea of "Unchanged" but perhaps I am missing the Vision
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 04-Oct-2010 at 1:15pm
midnit;

After drilling into it further, we've discovered that it is a bug. I assume that you're calling the import with MergeStrategy.OverwriteChanges, correct?
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 06-Oct-2010 at 12:38pm

Yes, that is correct.

Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 06-Oct-2010 at 3:29pm
midnit;

The bug has been fixed. I have an EAP for 6.0.6 here if you wish to download it. Let me know.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down