New Posts New Posts RSS Feed: EntityProperty.GetValue(object entityBase, EntityVersion version) doesn't return original version
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EntityProperty.GetValue(object entityBase, EntityVersion version) doesn't return original version

 Post Reply Post Reply
Author
afrizal.chen View Drop Down
Newbie
Newbie
Avatar

Joined: 17-Dec-2008
Location: Singapore
Posts: 21
Post Options Post Options   Quote afrizal.chen Quote  Post ReplyReply Direct Link To This Post Topic: EntityProperty.GetValue(object entityBase, EntityVersion version) doesn't return original version
    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.

Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
afrizal.chen View Drop Down
Newbie
Newbie
Avatar

Joined: 17-Dec-2008
Location: Singapore
Posts: 21
Post Options Post Options   Quote afrizal.chen Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down