POCO Data Transfer Objects #3527
-
We're in the midst of migrating an existing CSLA4 app to CSLA5 and at the same time move to a 3-tier architecture. We've found that fetching lists of BusinessBase objects was slower and resulted in larger payloads than if we used DataSets and populated our business objects from these as required. The issue we're facing now is that CSLA does not want to serialize/deserialize DataSets in 3-tier. As an alternative, we're investigating the use of lighter POCO DTOs to get data across the data portal. We've come across the MobileObject class and are interested in using it instead of BusinessBase as it doesn't appear to come with all the extra toppings. We have attempted to implement a DTO that inherits from MobileObject, but the DTO never contains the data once it gets back to the client side of the data portal. Based on some posts here https://github.com/MarimerLLC/cslaforum/issues/909 and here https://github.com/MarimerLLC/csla/issues/2148 we've tried to implement GetState and SetState but these have not resolved the issue. Are there more requirements for using MobileObject? Here's an example of the POCO DTO
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
My apologies for the somewhat premature post. I managed to get this working by overriding OnSetState and OnGetState. Here's the working example:
|
Beta Was this translation helpful? Give feedback.
-
I am curious as to why you are flowing DTOs through the data portal? Normally a DTO exists purely within the Data Access Layer to provide a neutral abstraction so you can swap out different types of data access frameworks without impacting the object-data mapping to get the data into your business domain objects. In a typical CSLA app, the Interface and Interface Control layers interact purely with business domain types, not dumb data containers like a DTO. |
Beta Was this translation helpful? Give feedback.
-
When you say that you have repeated header/definition data, I interpret that as meaning you have a parent/child relationship, such as an order with lines. Without understanding your full business environment, I cannot make a specific recommendation. However, I am highly sensitive to data performance. One of our core edit use cases is a bill of materials which supports unlimited nesting of components. Each component has multiple child properties. Users load a single BOM with over 10000 unique components in just a few seconds using a three-tier model (Winforms / IIS / SQL Server). The business object is fully instantiated with one call to the IIS process. You should be able to encapsulate header data in a single instance and not have that information duplicated when the business object is setialized. We use a variety of techniques to avoid duplication in scenarios where header data needs to be shared with the children. With more context, I might be able to share some specific patterns. If your data isn't editable, the read-only classes are more lightweight. |
Beta Was this translation helpful? Give feedback.
My apologies for the somewhat premature post. I managed to get this working by overriding OnSetState and OnGetState. Here's the working example: