json-api-dotnet/JsonApiDotNetCore

Filtering using a udf

alnotas opened this issue · 2 comments

Greetings everyone

I need to be able to filter a resource of mine using a udf as part of the comparison.

I have a table 'Customer' that has some fields that are encoded. I have a Db udf 'nvarchar dbo.DecryptData(byte[])' and I want to be able to write a filter like
/api/v1/customer?filter=equals(DecryptData(firstName),'Theodore')
and this to be translated in the EF Core query like
...WHERE dbo.DecryptData(firstName)='Theodore' ...

Customer.FisrtName is a varbinary field in the Db and is mapped as byte[] in my resource

Is this type of filtering possible?
I've tried by overriding the OnApplyFilter but nothing has worked so far.

VERSIONS USED
JsonApiDotNetCore version: 5.5.1
ASP.NET Core version: 8.0.6
Entity Framework Core version: 8.0.4
Database provider: SQL Server 14.0.2052.1

Yes, this is possible without changes to JsonApiDotNetCore itself. And it's actually a lot easier than suggested in the StackOverflow question. I have a working sample available, where the decrypt function nicely composes with existing filter functions such as and/or/not. It also works on includes and nested endpoints, such as /blogs/1/posts.

Unfortunately, our communications have stalled again. I'll share the sample once you've provided the operations minimal repro for #1566 that we discussed over email.