Hello LLBLGEN Team,
I have been using LLBLGEN for 20 years, and my project has grown quite large (WinForm). Now, I’m migrating it to Blazor Server – the LLBLGEN class library will be maintained as much as possible to continue using my custom code.
So, my Blazor Server project uses the class library that is generated with LLBLGEN 5.11.
LLBLGEN Pro Runtime Framework, Self Service, Two Classes, Netstandard 2. Library name: DAL
(By the way, maybe I should upgrade it to .NET 8?…)
In the DAL class library, I’ve added a custom class called “SessionService.” It handles login and stores some session data. This class is registered in:
Program.cs
as a Scoped Service:
builder.Services.AddScoped<SessionService>();
Within the Blazor app, Dependency Injection works fine.
However, I also need this Scoped Service in my entity classes.
How can I achieve Dependency Injection into the LLBLGEN class library (DAL) from the Blazor level?
I tried adding a static variable to the CommonEntityBase. This actually works, but in a multi-user environment, a static solution is not ideal...
Why do I need this?
In CommonEntityBase, I’ve extended the “OnSave” event to log some data, including the username. This username is stored in the SessionService, and I would like to access it within the event.
However, I cannot extend the constructor or event with parameters (Dependency Injection).
Do you have any tips for me?
Thank you very much!