One possible solution, if you are using EF core 9:
Link to outer source: https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-9.0/whatsnew#force-or-prevent-query-parameterization
Link to answer with example: https://stackoverflow.com/a/79202507/6643940