I was wondering if the old value of a property in the Entity is still available when the new value is being evaluated. I would need this to conditionally prevent changes to certain properties. We now use the

Regards Paul

asked Sep 03 '13 at 07:01

Paul%20Sinnema's gravatar image

Paul Sinnema

One Answer:

Hello Paul,

old value typically is not available because validation is delayed until transaction commit attempt or explicit user call to Session.Validate(). This means any changes to the entities are already applied at the moment of validation.

answered Sep 05 '13 at 03:53

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov

I was afraid of that. We need to prevent changes after a state has changed. A way I thought would work is to compare old and new values and when they are not the same throw an exception. We now solved it in the onSettingFieldValue(). That is not a so clean solution in my opinion. It would be cleaner at the Validate() time. Any suggestions on how to cleanly solve this?

(Sep 05 '13 at 04:09) Paul Sinnema Paul%20Sinnema's gravatar image

Unfortunately that's all we have for such scenario.

Our standard validators support ConstrainMode.OnSetValue which does validation before assignment, but your case requires writing custom validation aspect which in turn requires a license for PostSharp.

Our future version would support such scenarios without any additional licenses.

(Sep 05 '13 at 04:34) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

Ah, I'll add TODO's for this future version. Thanks.

(Sep 05 '13 at 08:24) Paul Sinnema Paul%20Sinnema's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: Sep 03 '13 at 07:01

Seen: 9,238 times

Last updated: Sep 05 '13 at 08:24

powered by OSQA