Issue
Using any overload of ToDataSourceResult(Async) with a DataSourceRequest containing filter descriptors on an IQueryable provided by Entity Framework core 2.x, causes Entity Framework's "Query cache" to fill up for different filter values, leaking memory in the process. This is caused by using Expression.Constant in the generated expression trees for a DataSourceRequest's FilterDescriptors. Refer to https://github.com/dotnet/efcore/issues/14859 for more details about why this leaks memory.
Since Entity Framework's cache is always missed for new filter values, performance is also degraded due to this issue.
The issue is not present when using Entity Framework core 3 or greater. Apparently using Expression.Constant is not an issue on these version.
I have attached a minimal working example that illustrates the memory leak.
Fix
This issue can be fixed by changing FilterDescriptorExpressionBuilder.CreateValueExpression to not return a ConstantExpression, but a MemberExpression instead. Entity Framework 2.x will correctly parameterize the MemberExpression, causing the query cache to be hit correctly for queries that only differ in parameter values. It won't parameterize ConstantExpressions. Refer to https://stackoverflow.com/a/60516780/147993 for an example of generating a MemberExpression instead of a ConstantExpression.