Replies: 2 comments 2 replies
-
I've shelved my migration in another branch for now. I don't know why the DI isn't working within my business object when I migrated to CSLA 7., but I can access the services (logging, Dals, etc) elsewhere outside of the business objects. It likely has something to do with me missing something obvious that is needed in the configuration for the csla to use DI. In my app with CSLA 5.5.3, in addition to my other services being wired up in the Builder (IHostBuilder), the CSLA specific stuff I have is:
When I moved to CSLA 7, this is what I have:
Not sure if there is something that I did incorrectly here when configuring the CSLA to use DI? Any help / thoughts / guidance would be appreciated. thanks, Tim |
Beta Was this translation helpful? Give feedback.
-
Constructor injection isn't supported for CSLA-derived types. In other words, there's no ctor injection for business classes. This is largely because those types are mobile and they get serialized/deserialized in various scenarios (n-level undo and the data portal most commonly). I don't know that it is realistic or desirable to require that all potentially injected services are declared on by client and server - that seems like a nightmare for most folks. Instead, the data portal implements parameter injection at a method level for data portal operation methods. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
After delaying the migration of my apps from CSLA 5.5.3 to CSLA 6+, I decided to take the plunge today with one of my small apps, which is a console app in .net 6.
We've had DI (injecting our services via the constructor) in this console app already, but we were using the static DataPortal in CSLA 5.5.3.
I just migrated the app to CSLA 7 over the past two days. I believe I have everything configured properly as my configured services are initialized and working properly in the console app. For example, the Serilog service is working within the console app when the app is running.
My issue arises when I Fetch my first business object. The parameterless constructor is called (and not the constructor with the injected services). The first line in the Fetch method is a logging statement. At this point the _logger is null.
I am calling AddCsla as part of my configuration of the console app. I'm just wondering if constructor injection is no longer possible in the CSLA 7 (doubtful) or is there something I'm missing.
I've been through the Upgrade To CSLA 6 documentation many times and can't see something obvious that I missed.
Any help would be appreciated. Thanks in advance!
Tim
Beta Was this translation helpful? Give feedback.
All reactions