Example of using the Saved Event in a Master/Detail scenario

Example of using the Saved Event in a Master/Detail scenario

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

tsvideo posted on Monday, October 28, 2013

Is there an Example of using the Saved Event  ?

My Scenario:
a WPF MVVM Master/Detail App with two ViewModels, one for a ReadOnlyList To select an Item and one for a EditableRoot BO of the selected Item.
My Problem is, i want to get the Saved Event of the EditableRoot to Reload the ReadOnlyList in my Main ViewModel after Saving the EditableRoot.

I'm Using CSLA 4.5. Thank you for an answer !


skagen00 replied on Monday, October 28, 2013

Under that sort of scenario I might consider to have a method on the read-only child class like RefreshForChanges(EditableRoot savedObject) - where EditableRoot is your editable root class you just edited and saved.  You'd want to do a validation that the ID of the editable root matches the ID of the child, throwing an exception if they don't match.

If you haven't explicitly added INotifyPropertyChanged to your read-only class hierarchy you'll need to do that (I think we manually added it in our base classes as I think CSLA didn't - I could be wrong).

In your read-only child, just load the properties from the saved business object as you need to and invoke OnPropertyChanged so they refresh in the UI.

Anyway, that is probably what I would do... then you don't have to hit the server to get the changes you already have in memory from the saved editable root.

Copyright (c) Marimer LLC