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: Predicates as a static and building complex expressions #855

Closed
CREFaulk opened this issue Oct 23, 2023 · 3 comments
Closed

Question: Predicates as a static and building complex expressions #855

CREFaulk opened this issue Oct 23, 2023 · 3 comments
Labels
Source: Community Originated from the Community. Type: Question Issue is a Question or a Discussion.

Comments

@CREFaulk
Copy link

CREFaulk commented Oct 23, 2023

My main issue is that Predicates is a static class and I need to build the predicates value within a reusable method with fairly complex logic which can't simply be created with a single expression. The conditions used are configurable so I can't simply hardcode a simple set of statements; I need a reusable method to create the Predicates / query conditions.

PredicateBuilder is strictly internal with the .net client so I can't use instances of that.

To put it another way, I have a complex calculated Lambda expression (System.Linq.Expression) I need to convert to Predicates and use for querying Hazelcast without simply pulling the entire set of records into a list first or building the results one record at a within an Enumerator.

Could anyone offer some insights or suggestions on how to accomplish this? It seems like I could have done this with the Java client but not the .net client but I never used that language with Hazelcast.

Thanks!

Edit: Building sql conditions and using the SQL predicate instead worked. I would suggest perhaps adding functionality to PredicateBuilder to be able to instantiate an objects with the predicate conditions with a method for ToPredicates() to return the static Predicates might be helpful.

@emreyigit
Copy link
Collaborator

emreyigit commented Oct 30, 2023

Hey @CREFaulk,

Have you looked at Hazelcast.Net.Linq.Async package or considered to use SQL directly instead predicates?

https://hazelcast.github.io/hazelcast-csharp-client/latest/doc/extensions/linq.html
https://hazelcast.github.io/hazelcast-csharp-client/latest/doc/sql.html

@emreyigit emreyigit added Source: Community Originated from the Community. Type: Question Issue is a Question or a Discussion. labels Oct 30, 2023
@CREFaulk
Copy link
Author

Hi @emreyigit Good suggestions. I was able to use the sql predicates fairly easily but the Linq extension would have been simpler to implement since I already had compiled queries for that with my old self-written memory caching. I didn't find the documentation right off unfortunately, so thanks for the links!

@emreyigit
Copy link
Collaborator

You are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source: Community Originated from the Community. Type: Question Issue is a Question or a Discussion.
Projects
None yet
Development

No branches or pull requests

2 participants