How often should DataPortalTextController be hit when saving a BO in Blazor Wasm? #2823
-
Using Csla 5.5.2 I've created a form to edit an existing business object. I'm binding that object to an injected ViewModel and triggering a SaveAsync on the ViewModel when the form is submitted. The form takes a little while to save and return. At first it was a second or two, but as I kept adding more controls to my form that save keeps taking longer and longer. When I look at the DevTools console, it seems to be hitting the PostAsync method of my DataPortalTextController a bunch of times when the save is initiated, and that amount increases the more controls I add to the page. As a bare bones test, I removed all controls from the form except for the save button to submit the form and I see the following in the Console Log when the button is clicked:
So my question is is this normal? Should the ViewModel trigger so many calls to the DataPortal controller? I would have assumed it would only be making one call. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
I'm following back up with this. I was going down the wrong path with the calls to the DataPortalTextController. All of those calls are legitimate based on my validation rules hitting the database. I've pinpointed my issue having to do with calling StateHasChanged in the ModelPropertyChanged Event Hander for the ViewModel. When I write the changed property name out to the DevTools console it looks like a bunch of meta properties are being changed after the call to the DataPortalTextController, and before the OnModelSaved handler is invoked. Now my business object has 5 child collection objects on it, so that may have something to do with all those calls, but is that normal to keep changing the meta properties on the ViewModel for all child objects after the save? And is there a suggested way / best practice to ignore these properties during the save so that StateHasChanged isn't being called all of those times? Here's what my console looks like:
|
Beta Was this translation helpful? Give feedback.
-
Also now an issue: #2833 |
Beta Was this translation helpful? Give feedback.
I'm following back up with this. I was going down the wrong path with the calls to the DataPortalTextController. All of those calls are legitimate based on my validation rules hitting the database.
I've pinpointed my issue having to do with calling StateHasChanged in the ModelPropertyChanged Event Hander for the ViewModel. When I write the changed property name out to the DevTools console it looks like a bunch of meta properties are being changed after the call to the DataPortalTextController, and before the OnModelSaved handler is invoked. Now my business object has 5 child collection objects on it, so that may have something to do with all those calls, but is that normal to keep changin…