Using ServiceStack Ormlite global filters with Session -
i want alter example found here modifyby populated session's username every time change made. possible?
you need singleton access access username need populate in either reqeustcontext
or asp.net's httpcontext.current.items
dictionary, e.g:
globalrequestfilters.add((req,res,dto) => { requestcontext.instance.items["username"] = req.getsession().userauthname; });
which can access inside updatefilter
, e.g:
ormliteconfig.updatefilter = (dbcmd, row) => { var auditrow = row iaudit; var username = requestcontext.instance.items["username"] string; if (auditrow != null) auditrow.username = username; };
note: "username" work within context of http request.
Comments
Post a Comment