serialize variable on BusinessListBase?

serialize variable on BusinessListBase?

Old forum URL:

swegele posted on Friday, March 14, 2014

If I add a private variable on my or can I serialize it so it is still there on the other side of the WCF portal?

Say like this?

TestList BusinessListBase(of Test)

private mTestString as String

I assumed the BusinessListBase would preserve and serialize variable just like BusinessBase but apparently not.

I am tracking a list of issues to report to the parent when IParent is set in SetParent after DataPortal call.  I override SetParent and alert the root parent in there.

Any ideas


ajj3085 replied on Sunday, March 16, 2014

You can't.  Databinding will no look for properties on collections and so Csla doesn't support it either.  what you'll need to do is create a class and put the property there as well as the property for the collection, but I'm not exactly sure what you're trying to do.

It sounds like issues can be edited by themselves and so I'm not sure why its reporting to another object.  normal you'll not need to call setparent yourself.

swegele replied on Sunday, March 16, 2014

I discovered this was ONLY happening on 1 of 4 child collections.  This one is not lazy loaded and uses the ChildFetch_DataPortal.  All the other collections (which are lazy loaded) serialize their variables correctly across the full dataportal fetch.


swegele replied on Sunday, March 16, 2014

The BusinessListBase DOES serialize / deserialize private variables correctly but only over a full dataportal call.

Normally I would handle it like you say in the children of the list.  But the problem is if there is a Referential Integrity problem, I skip loading that child.  But I am alerting the user of which child type and id caused the problem and which object & id it was looking for.  So the user can save the root object but they are alerted to the problem with a warning rule. 

If there is no child to break a rule on, then I have to have the list alert its parent since BusinessListBase doesn't have broken rules.

I got it working, by handling the lazy loaded and non-lazy loaded listbases differently.  Cool feature.

Root give a nice list of any RefIntegrity issues from n-levels down the tree:

"ChildType (id-1234) was unable to find it's referenced TargetType (id-5678)"

sash_kr replied on Monday, March 17, 2014

What a small world Smile. I have the same question: (I had posted it at the same day).

I guess it should work, but Andy says - NO! I'm pretty sure Andy is a cool guy Smile. But I can't believe that it will not work Crying.


skagen00 replied on Monday, March 17, 2014

I do believe you may be able to use OnGetState/OnSetState to manually serialize and deserialize fields for a collection, and you should be able to databind to these properties in XAML, etc.

It's not clean, and under such circumstances i'd just introduce the root object containing the collection and have the properties in the root as advised above, but I do believe it can be done.

Maybe I am not recalling properly, but I think so.

JonnyBee replied on Monday, March 17, 2014

@skagen00 - yes, you are correct. 

See my answer in the other thread: 

ajj3085 replied on Monday, March 17, 2014

Hey Jonny, so is this considered supported then, or could a future version of Csla break this? 

JonnyBee replied on Tuesday, March 18, 2014

Hi Andy,

My general recommendation/pattern is to create a new "Parent" and add properties to this parent. 

Strictly speaking - csla (for as long as I have used used it since 2.x) - has allowed you to have serialized fields on a list object but with the following constraints:  

I do not believe we will ever want to merge BusinessListBase / BusinessBase into a new "super base class"  so I will stick with my general recommendation.

Copyright (c) Marimer LLC