| Author |
Share Topic Topic Search Topic Options
|
smi-mark
DevForce MVP
Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
|
Post Options
Quote Reply
Topic: BUG - RejectChanges Posted: 20-Jun-2010 at 12:10pm |
|
Hi,
I've found a bug in the RejectChanges method. RejectChanges does not return relation properties back to what they were.
Example:
License LicenseTypeId = 1 LicenseType = LicenseType ('Type 1')
CHANGE LicenseType = 'Type 2'
License LicenseTypeId = 2 LicenseType = LicenseType ('Type 2')
Now call RejectChanges() and it looks as follows:
License LicenseTypeId = 1 LicenseType = LicenseType ('Type 2')
|
 |
smi-mark
DevForce MVP
Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
|
Post Options
Quote Reply
Posted: 20-Jun-2010 at 12:48pm |
|
My temporary solution is to do the following:
Public Property LicenseType2 As LicenseType Get Return Me.EntityManager.GetQuery(Of LicenseType).Where(Function(l) l.Id = Me.LicenseTypeId).FirstOrNullEntity() End Get Set(ByVal value As LicenseType) Me.LicenseTypeId = value.Id End Set End Property
Now I can bind to LicenseType2 and reject changes shows the correct value.
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 21-Jun-2010 at 1:47pm |
Originally posted by smi-mark
Hi,I've found a bug in the RejectChanges method. RejectChanges does not return relation properties back to what they were. |
I have duplicated this issue and entered a bug report.
All please note that RejectChanges() will NOT undo changes in related child entities; e.g., if you add Order y to Customer x, rejecting changes on Customer x will not remove the association between Order y and Customer x, because that change actually took place on the Order, not the Customer.
But in the case of changing a relation involving a parent, RejectChanges() should undo the change, since the foreign key lives on the child. For example, if you change the Customer associated with an Order, rejecting changes on the Order should undo the change in the relation. This is smi-mark's use case.
DevForce is undoing the foreign key value, but the relation is still returning the original parent. We'll get it fixed.
Edited by GregD - 21-Jun-2010 at 1:48pm
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 24-Jun-2010 at 3:49pm |
|
Bug has been fixed. Fix will go out with the next DevForce 2010 release.
|
 |
smi-mark
DevForce MVP
Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
|
Post Options
Quote Reply
Posted: 28-Jun-2010 at 2:04pm |
|
Thanks Greg. Is there an expected release date? We have a project going into production in just over a month, so I'd like to have this in before then!
Mark
|
 |
ting
IdeaBlade
Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
|
Post Options
Quote Reply
Posted: 28-Jun-2010 at 5:51pm |
|
Hi Mark - We're currently scheduled to release in the last two weeks of July.
|
 |
mikewishart
Groupie
Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
|
Post Options
Quote Reply
Posted: 02-Aug-2010 at 4:06pm |
|
In DevForce 6.0.4 Rejecting changes for the entire EntityManager does not seem to restore a parent's relationship to the deleted child. Should it?
child.EntityAspect.Delete(); EntityManager.RejectChanges();
Parent.children - does not contain child; however, the EntityManager does show the child with no changes AND its parent has been restored properly.
I'm unsure if this is proper behavior, but if it is, I'm not sure how to restore the child relationship.
Thanks for any help.
Edited by mikewishart - 02-Aug-2010 at 4:22pm
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 05-Aug-2010 at 4:50pm |
Originally posted by mikewishart
In DevForce 6.0.4 Rejecting changes for the entire EntityManager does not seem to restore a parent's relationship to the deleted child. Should it?
child.EntityAspect.Delete(); EntityManager.RejectChanges();
Parent.children - does not contain child; however, the EntityManager does show the child with no changes AND its parent has been restored properly.
I'm unsure if this is proper behavior, but if it is, I'm not sure how to restore the child relationship.
Thanks for any help.
|
This looks like a bug - the parent's collection of children should again contain the deleted and restored child. I've reproduced it in a test case and created a Defect Report in our issue system.
I don't know of a good work-around, but I'll ask around for ideas.
Of course, if you know that a given entity belongs in a parent's collection of children of that type, you can explicitly add it to that collection.
|
 |
mikewishart
Groupie
Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
|
Post Options
Quote Reply
Posted: 05-Aug-2010 at 5:07pm |
|
Thanks Greg, you've been a big help.
Mike
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 06-Aug-2010 at 7:42am |
|
You're most welcome, Mike. Your very clear and nicely isolated reports are really a tremendous help to us in isolating and correcting problems in DevForce. We appreciate your patience!
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 10-Aug-2010 at 1:39pm |
Originally posted by mikewishart
In DevForce 6.0.4 Rejecting changes for the entire EntityManager does not seem to restore a parent's relationship to the deleted child. Should it?
child.EntityAspect.Delete(); EntityManager.RejectChanges();
Parent.children - does not contain child; however, the EntityManager does show the child with no changes AND its parent has been restored properly.
I'm unsure if this is proper behavior, but if it is, I'm not sure how to restore the child relationship.
Thanks for any help.
|
This bug has been fixed. Fix will be in the next release.
|
 |
rhaney
Newbie
Joined: 06-Jul-2010
Location: Orange, CA
Posts: 12
|
Post Options
Quote Reply
Posted: 10-Aug-2010 at 5:07pm |
Greg,
Can you also test one more thing? I am unable to revert changes to a complex type.
In my model:
Name is a complex type having three string properties, First, Last, Middle.
Person has a complex property of type Name.
If I materialize a person, change the last name, and call revert changes, it doesn't revert the name.
Thanks!
|
 |
rhaney
Newbie
Joined: 06-Jul-2010
Location: Orange, CA
Posts: 12
|
Post Options
Quote Reply
Posted: 10-Aug-2010 at 5:08pm |
|
FYI, I call revert changes on the instance of Person.
|
 |