EntityProperty.GetValue(object entityBase, EntityVersion version) doesn't return original version
Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1681
Printed Date: 20-Sep-2025 at 6:49pm
Topic: EntityProperty.GetValue(object entityBase, EntityVersion version) doesn't return original version
Posted By: afrizal.chen
Subject: EntityProperty.GetValue(object entityBase, EntityVersion version) doesn't return original version
Date Posted: 11-Mar-2010 at 1:03am
I have a case where I need to compare an original and current version of an EntityProperty, so I used the API "EntityProperty.GetValue(object entityBase, EntityVersion version)".
This API works for DataEntityProperty, but when it comes to NavigationScalarEntityProperty, it always returns the Current version.
See the screenshot attachment of my watch panel.
|
Replies:
Posted By: IdeaBlade
Date Posted: 11-Mar-2010 at 3:54pm
It should probably be considered a bug that GetValue() returns anything for a scalar navigation property. We don't really attempt to keep track of original values for properties that aren't part of the core entity. If the property happened to be a generated one representing an entity related many-to-many, keeping up with that information would be an especially complex affair.
But assuming the property represents an entity related in a one-to-many or one-to-one association, you can get at what you want by using the EntityProperty for the associated foreign key (e.g., HeadPerson_fk_InternalIdEntityProperty). Since that foreign key is part of the core entity, we do keep a copy of its original value.
|
Posted By: afrizal.chen
Date Posted: 11-Mar-2010 at 7:28pm
Thank you for the clarification.
And your suggestion to get the Entity using the associated foreign key works for me.
|
|