Filtering using a udf
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.
Greetings Sorry for the miscommunication but I am on my summer leave. I will return to office on August the 19th. Thank you.
On Fri, Aug 2, 2024, 10:59 Bart Koelman @.***> wrote:
Yes, this is possible without changes to JsonApiDotNetCore itself. And it's actually a lot easier than suggested in the StackOverflow question https://stackoverflow.com/questions/78758507/jsonapidotnetcore-and-filtering-using-a-udf. 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 https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1566 that we discussed over email.
— Reply to this email directly, view it on GitHub https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1599#issuecomment-2264801081, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJSHF4H7UGLRKS4W5L5TXZTZPM36PAVCNFSM6AAAAABK77IX7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRUHAYDCMBYGE . You are receiving this because you authored the thread.Message ID: @.***>