In ADO DataRow world, We have the mechanism to get Original Value for any Column of the Row.
This is required in day-to-day business problems. We have to frequently compare before doing some processing the current value of the property with Original Value of the property ( the value that was fetched from the database ).
This requirement is at both Server and Client Side.
Que: How Do I get the Original value of the property that was fetched from the database and compare that with current value of the property??
Any help / suggestion is highly appreciated.
You have 2 basic options.
Simply create some extra fields with ReadOnly Properties and when you set the value of Field1 during Fetch you also set the value of orig_Field1. This way you carry around the extra information and have access to it at any time. I do this for selected BOs and selected properties in those BOs. But not for all fields for all BOs.
As I recall the new managed properties can be extended to allow additional information to be carried around. This would include an Original Value. (And IsDirty for the the property itself which returns currVal <> OrigVal - which allows a value to be changed and then changed back to the orig inal value and thus state the Property itslef is not dirty even though the BO IsDirty.)
There is a huge thread on this topic - it was when Rocky first proposed it. I believe he concluded that he would not provide this type of information as a built-in part of CSLA but that he would allow CSLA to be extended for those developers who want this sort of thing. You'd have to find and review that thread ofr more details - unless some else can explain it more fully in this thread.
Thanks for your reply Joe,
Keeping the old value with the property is an overhead as it doubles the size of the entity. You are right it should be done for specific required properties only. But some of the core tables we have like sales order or production order have more than 300 fields/properties each. and we need old values for a lot of them. So in WCF mode it becomes a huge overhead for serialization.
Can I create non-serializable client-side only dictionary or something more appropriate container, After fetch of the entity I can fill this dictionary and anytime when we need old value we can get the value from this dictionary.
I can compromise by re-fetching the entity from the database, fill my non-serializable server side only dictionary and provide the standard mechanism of getting the old value.
If the above theory is practically efficient to do, then Could you please provide me an example on how to do this.
Also, if you implement old values using the managed propety method, you should be able to use nullable types, and only store the value if it has actually changed. That may reduce the size of the stream as well, and you could find out of the value ever changed since the BO was loaded.
Sounds good. Pardon my ignorance, Could you please provide one simple example for managed property method?
Copyright (c) Marimer LLC