How to: Nonserialized or notundoable managed properties?

How to: Nonserialized or notundoable managed properties?

Old forum URL: forums.lhotka.net/forums/t/7763.aspx


rsbaker0 posted on Saturday, October 10, 2009

I had submitted this for the wish list about a year ago (http://forums.lhotka.net/forums/post/27850.aspx).

However, assuming that this won't become part of CSLA, can you think of a way I might implement this myself?

I'm more concerned about serialization over the wire, so one thought I had that wouldn't be a breaking change would be to have you add a virtual CloneForSave() method to BusinessBase that would just call Clone() as the default implementation. Then I could replace it with one that would inspect the PropertyInfo and discard those that aren't intended to be serialized before returning the cloned object.

Right now, I'm using managed properties because the benefit of the automatic features it provides outweighs the performance issue, and also I can "reset" the property from the comon base class (mainly for lazy-loaded properties) and cause it to be reloaded on the next get. So, I can't use a private backing field when I need this ability.

Any other ideas welcomed...

RockfordLhotka replied on Sunday, October 11, 2009

I put it on the wish list, but haven't had time to try and figure out an implementation yet. It isn't trivial, because I suspect it will mean storing field values in 2 or 3 arrays instead of just 1 like today, and storing the metadata somewhere (in the PropertyInfo<T> probably) so indicate which array to use.

If it was just MobileFormatter it would be pretty easy, because I can make the serializer smarter. But since we're also talking about BinaryFormatter and NDCS the problem is substantially harder.

rsbaker0 replied on Sunday, October 11, 2009

Thanks.

Incidentally, I didn't mean for that to come across as a whine -- I was just wondering if there was a possible workaround in case this feature had a limited audience or otherwise didn't fit in.

Copyright (c) Marimer LLC