Print Page | Close Window

BUG - RejectChanges

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1901
Printed Date: 21-Apr-2026 at 10:29pm


Topic: BUG - RejectChanges
Posted By: smi-mark
Subject: BUG - RejectChanges
Date 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')






Replies:
Posted By: smi-mark
Date 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.


Posted By: GregD
Date 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.


Posted By: GregD
Date Posted: 24-Jun-2010 at 3:49pm
Bug has been fixed. Fix will go out with the next DevForce 2010 release.


Posted By: smi-mark
Date 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


Posted By: ting
Date Posted: 28-Jun-2010 at 5:51pm
Hi Mark - We're currently scheduled to release in the last two weeks of July.


Posted By: mikewishart
Date 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.



Posted By: GregD
Date 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.


Posted By: mikewishart
Date Posted: 05-Aug-2010 at 5:07pm
Thanks Greg,  you've been a big help.

Mike


Posted By: GregD
Date 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!


Posted By: GregD
Date 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.


Posted By: rhaney
Date 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!


Posted By: rhaney
Date Posted: 10-Aug-2010 at 5:08pm
FYI, I call revert changes on the instance of Person.



Print Page | Close Window