Editable list, but can't add/remove items #3540
-
I'm working on moving us to HttpProxy, and I've hit a problem I'm not sure what the recommended approach is. Basically I have a BusinessListBase, which you can only fetch from the server. The list is the UOW (so all changes to the child items are saved or discarded as a group), but you shouldn't be able to add or remove items from the list, just edit the existing instances. So we added an IsReadOnly property, and overrode the InsertItem & RemoveItem to throw an exception if IsReadOnly. We override onGetState/OnSetState to keep the value across the wire (its only set server side though). I guess with how WCF serialized things, it didn't use InsertItem to recreate the list. But I think now that we're using HttpProxy, Csla does use InsertItem, and its after the OnSetState is called, so IsReadOnly is true and our exception gets thrown. Is there some other thing I need to do to keep this behavior, or will it just not work given how HttpProxy/MobileFormatter work? I'm on Csla 4.5.2 and .Net Framework 4.7.2. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
If there is a way you can detect the object is being transported across portal you could set the ReadOnly to false temporarily and then use the OnDeserialized event to set the readonly property back to true or something like that? |
Beta Was this translation helpful? Give feedback.
-
Can you set AllowAdd and AllowRemove to false? |
Beta Was this translation helpful? Give feedback.
-
I’ll see if I can poke at a little demo project today and get it to work.
…On Wed, Nov 8, 2023 at 7:11 AM ajohnstone-ks ***@***.***> wrote:
I don't know, that's why I'm here :-) I think OnDeserialized though is
only for the old school remoting & maybe wcf. I can try overriding that and
see if its called, its a good idea.
—
Reply to this email directly, view it on GitHub
<#3540 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABUM5P3GN2XDD6ISFI7PJYDYDOHJNAVCNFSM6AAAAAA7B2OYFCVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TKMJRGI2DS>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
I believe you want to implement ISerializationNotification to get a
Deserialized
method invocation when deserialization of the instance (and its children) is complete.csla/Source/Csla/Serialization/Mobile/MobileFormatter.cs
Line 312 in 969bee6