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

Add SQL LIKE implementation for the in-memory evaluator. #150

Closed
fiseni opened this issue Sep 4, 2021 · 0 comments · Fixed by #153
Closed

Add SQL LIKE implementation for the in-memory evaluator. #150

fiseni opened this issue Sep 4, 2021 · 0 comments · Fixed by #153
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@fiseni
Copy link
Collaborator

fiseni commented Sep 4, 2021

Starting with version 5 of the package, we introduced in-memory evaluators. The usage is as follows:

List<Customer> customers = new List<Customer>();
var spec = new CustomerByNameSpec("somename");
var result = spec.Evaluate(customers);

This greatly simplifies the usage if you need to apply a specification to some collection you already have in hand. Not rarely, in your domain model, you might need to filter a given collection (it might be the navigation of your entity). If that action is required in several places, you may want to encapsulate it in a separate specification, and then just apply it wherever you need it. That's the use-case, generally.
Since the in-memory evaluator operates against in-memory collections, it acts independently from the plugin packages (EFCore, EF6). Therefore, all ORM-specific features that the specification may contain are excluded from this evaluation. The following features won't be evaluated:

  • Include chains
  • AsNoTracking
  • AsSplitQuery
  • AsNoTrackingWithIdentityResolution

But, unfortunately, since the Search feature is evaluated to SQL Like by the plugin packages, it is excluded as well. This is quite inconvenient. If I have applied Search in my specification, I'd like to be processed during in-memory evaluation too.

The solution would be to implement the SQL LIKE operator in C#. But, LIKE is a very rich and powerful operator with plenty of options, and trying to match and mimic the behavior is not a simple task.

I'm open to ideas here. Does anyone know of such an implementation?
My first thought was to check how that is implemented in EntityFrameworkCore.SQLite. This SO post might also be helpful

@fiseni fiseni added enhancement New feature or request help wanted Extra attention is needed labels Sep 4, 2021
@fiseni fiseni added this to the 6.0 milestone Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant