CSLA 6 and static properties with DataPortal?? #3107
-
Hello,
So the problematic rows here are: Another problem is on business objects we have these:
How should these be changed? Is there any examples for CSLA 6, business objects, BusinessListBase and WPF? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
@RocketLabsDev Yes, you are right. The data portal is now instantiable and retrieved using dependency injection. This is the big change from CSLA 5 and earlier. There is an up to date WPF sample in the Samples folder of the repo, at https://github.com/MarimerLLC/csla/tree/main/Samples/WpfExample I haven't played with this sample myself as I don't work with WPF, but it should be fairly self-explanatory. Beware that the ProjectTracker sample app is one of the only ones in the repo that has not been updated to CSLA 6 yet. ProjectTracker is quite a big sample app and nobody has found time to work all of the way through it yet. Other people have had the same questions on their upgrade journey, so there are lots of discussions on the subjects you will encounter. I would recommend searching over this list of discussions for lots more help and information as you work through your upgrade. |
Beta Was this translation helpful? Give feedback.
-
I've discussed this in other threads, but there are three main solutions. Use IDataPortal directlyAs you note, you can inject an IDataPortal and use it directly in the viewmodel. I think this is a fine solution, but does not provide intellisense on parameters. Create a factory classYou can create a factory class, and inject IDataPortal into the factory. The factory then implements methods that require parameters and provide them to the data portal. Similar to the static factory concept, but now the factory is an instance type that can be injected into the viewmodel. This is probably the best solution overall. Expose a global IDataPortal creator methodThis only works in some app types, like WPF!! In your The upside to this is that you can continue to use your static factory methods. The downside is that this technique doesn't work in modern UI types like Blazor. I think this is a short-term solution for migration, but still leaves you with technical debt that'll need to be addressed at some point. |
Beta Was this translation helpful? Give feedback.
@RocketLabsDev Yes, you are right. The data portal is now instantiable and retrieved using dependency injection. This is the big change from CSLA 5 and earlier.
There is an up to date WPF sample in the Samples folder of the repo, at https://github.com/MarimerLLC/csla/tree/main/Samples/WpfExample
I haven't played with this sample myself as I don't work with WPF, but it should be fairly self-explanatory.
Beware that the ProjectTracker sample app is one of the only ones in the repo that has not been updated to CSLA 6 yet. ProjectTracker is quite a big sample app and nobody has found time to work all of the way through it yet.
Other people have had the same questions on their upgrade journey,…