Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Vogen in "dynamic" EntityFramework Core situations #699

Open
mkalinski93 opened this issue Nov 8, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@mkalinski93
Copy link

Describe the feature

Hello,

I´m working on a project, which heavily uses Vogen, that needs to filter values submitted by the FrontEnd, on the BackEnd with IQueryable.

I would say that 95% of the cases are doing great and I´m enjoying the work with Vogen so far.
Now I´ve encountered one specific type of problem that is drastically putting me into the corner.
I need to filter values with a "Contains" or "IN" operation. For example, I have a List of Guid/string supplied from the frontEnd that needs to filter the property 'Id: UserId' (that´s my ValueObject here). I will receive the property name "id" and a collection of Guid/String values.
The real problem starts here: Whenever I "dynamically" want to filter the database, I have limited choices:

  1. Use a custom library that parses strings into Expression - like Gridify, Dynamic.LINQ and so on
  2. Implement my own library - I´m not scared of
  3. Implement some sort of "EF.Property" butchery - not a fan of

But all three choices brought me back to a single point of failure - Type safety.
If the QueryFilter object doesn´t explicitely contains the type of UserId, either as an object or as a generic collection, I´m done. I would need to explicitely specify the type, otherwise EfCore cannot work with it.

Whenever I try to provide some sort of "dynamic filter", the ValueConverter of EfCore will be in charge, converting the values back and forth (Primitive <-> ValueObject) and I cannot use primitive types from the request as it expects the real ValueObject with correct type. The result will always be empty. And it makes sense. Now, after a few days of pain, I finally want to reliefe myself and write down this question. Is there anybody here, that has found a solution to it?

@mkalinski93 mkalinski93 added the enhancement New feature or request label Nov 8, 2024
@SteveDunn
Copy link
Owner

Hi, thanks for starting this discussion. It sounds like a common enough scenario, so I'm sure we can get something working.

Would you be able to provide a minimal repro that I could compile and run to see what needs to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants