How to get current AuthSession inside OrmLiteConfig.UpdateFilter

Looking for a way to use GetSession() inside the appHost where I defined the OrmLiteConfig.UpdateFilter. I want the name of the user inside a field as LastUpdatedBy. But therefore I need to get a handle to the Session to get this data.
I am using .net core.
I checked the code in the Service class to get the current session. I need the current Request in there but how to get that inside the AppHost context?

You can use request global filters to add username into RequestContext.Items and then use RequestContext.Items in your OrmLite UpdateFilter

GlobalRequestFilters.Add((req, res, dto) => {
    RequestContext.Instance.Items["username"] = req.GetSession().Username;

and in your update filter

OrmLiteConfig.UpdateFilter = (dbCmd, row) => {
    var username = RequestContext.Instance.Items["username"];
1 Like