Object Graph with child collection needing 'Replace' #4696
-
We have an object graph, where 'Client' is the main parent object and has a child 'Lineitems' collection. The way it works in the UI, we get an instance of our Client object. During interaction with the UI, users can update the entire object graph, including the child LineItems collection. We have provided a dropdown where users have the option to 'replace' the lineItems. Kind Regards |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
So the UI has a reference to the original Client instance and it has a reference to a separate LineItems collection (e.g. "new line items")? Can we presume that the instances within "new line items" are all "IsNew = True"? To stick with conventions, I would use the Clear method on the LineItems property of the Client instance and then call AddRange on the same property, passing the "new line items" instance. This will cause all of the previously existing instances to be changed to deleted status. When you save Client, the model DAL code should delete the existing instances and insert the new instances. |
Beta Was this translation helpful? Give feedback.
-
@hurcane Thank you Sir.
I am going to follow this route. This is an older code base. Does the default implementation of 'DataPortal_Update()' Kind Regards |
Beta Was this translation helpful? Give feedback.
I have no understanding of your complete use case because you stated, "only applies to fetch operation," and you stated, "interaction with the UI". There is no interaction with the UI during a fetch operation.
My general advice: