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

Improvement on Collection Filters #36

Open
4 tasks
enisn opened this issue Oct 18, 2021 · 3 comments
Open
4 tasks

Improvement on Collection Filters #36

enisn opened this issue Oct 18, 2021 · 3 comments
Assignees
Milestone

Comments

@enisn
Copy link
Owner

enisn commented Oct 18, 2021

See the origin of this issue:
#35

Possible Scenarios

There are 6 possibilities while generating filters for collections. 2 of them are already covered by AutoFilterer currently. Those possibilities depend on Property types of Filter and Source Objects. When a Filter object property is a collection, the query must be generated with Contains method. But there is more a couple of possibilities:

  • p => []
  • [] => {}
  • [p] => [p] (Contains method inside Any/All method. For MongoDb models)
  • [{}]=> [{}] ( Built Expression ({} => {}) inside All/Any methodto understand how to generate query.)

p property
[] array
[p] a property inside array
[{}] entire object inside array

@enisn enisn self-assigned this Oct 18, 2021
@enisn enisn added the feature label Oct 18, 2021
@enisn enisn added this to the v2.9 milestone Oct 18, 2021
@enisn enisn modified the milestones: v2.9, Backlog Jan 10, 2022
@mehmetuken
Copy link
Contributor

https://stackoverflow.com/a/41470943 this answer may help Collection of Complex Type.

@candoumbe
Copy link

candoumbe commented Jun 27, 2023

I did something similar with DataFilters and I ended up emitting the suitable Expression<Func<T, bool>> inside a Enumerable.Any when the targeted property is a collection (https://github.com/candoumbe/DataFilters/blob/2c826c80ed6c0a165a16181af8189eae6aadff13/src/Datafilters.Expressions/FilterExtensions.cs#L297)

@enisn
Copy link
Owner Author

enisn commented Jul 4, 2023

I did something similar with DataFilters and I ended up emitting the suitable Expression<Func<T, bool>> inside a Enumerable.Any when the targeted property is a collection (https://github.com/candoumbe/DataFilters/blob/2c826c80ed6c0a165a16181af8189eae6aadff13/src/Datafilters.Expressions/FilterExtensions.cs#L297)

It seems quite well,

Any & Contains are working well currently. The topic is about running all nested like All(Any(x => x)) or even much deeper All(Any(All(Contains()))). It will go deeper according to the nested filter objects. I'll check your repository, and if it does it exactly and compatible, I can refer to your project in the documentation for this purpose instead re-inventing the wheel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants