You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using Sieve's custom filter methods to achieve this functionality, but planning to migrate to Gridify.
Hello, I'm using MongoDb as database, where I have a couple of entities with sub-documents storing additional information, represented as IDictionary<string, string>.
e.g.
publicclassExampleEntity{publicIDictionary<string,string> Data {get;init;}}
Is it possible to achieve filtering based on the values of this Dictionary?
The keys of these dictionaries are not known, so I cannot just AddMap("data.key1"), AddMap("data.key2").
One solution would be to implement a custom operator, then cast the value to an IDictionary, but that seems like an overkill (and then I need to implement other custom operators for NotEquals, Contains, etc).
It would be great to have support on sub-documents, just like there is support for sub-collections. Maybe something like:
vargq=new GridifyQuery {Filter="prop{subKey} = John"};vargm=newGridifyMapper<TargetType>().AddMap("prop",(x,prop)=> x.Data[prop]);// would generate an IQueryable likeIQueryable<TargetType>().Where(e => e.Data["subKey"]=="John");
For reference, my current approach (using Sieve) looks like this:
publicIQueryable<ExampleEntity>DataValue(IQueryable<ExampleEntity>source,stringop,string[]values){if(values.Length !=2){returnsource;}stringkey= values.First();stringvalue= values.Last();if(op=="=="){source= source.Where(d => d.Data[key]==value);}// ... the rest of operators returnsource;}// whereIQueryable<ExampleEntity>source= MongoCollection.AsQueryable();// then GET /api/example?filters="DataValue==key1|value1"
Or maybe is it planned to support custom filter methods (like Sieve), where we have access to the IQueryable that is being filtered? (that's how we achieved search in our past projects)
e.g.
// really basic examplepublicIQueryable<ExampleEntity>Search(IQueryable<ExampleEntity>source,stringop,string[]values){stringvalue= values.First();// here we have the possibility to access the Queryable and to call database engine specific clauses like a Mongo text search.source= source.Where(d => d.Name.Contains(value)|| d.Description.Contains(value))
return source;}// then GET /api/example?filters="search==searchString"
```</div>
The text was updated successfully, but these errors were encountered:
Discussed in #164
Originally posted by ameckl May 12, 2024
Hello, I'm using MongoDb as database, where I have a couple of entities with sub-documents storing additional information, represented as
IDictionary<string, string>
.e.g.
Is it possible to achieve filtering based on the values of this Dictionary?
One solution would be to implement a custom operator, then cast the
value
to an IDictionary, but that seems like an overkill (and then I need to implement other custom operators forNotEquals, Contains
, etc).It would be great to have support on sub-documents, just like there is support for sub-collections. Maybe something like:
For reference, my current approach (using Sieve) looks like this:
Or maybe is it planned to support custom filter methods (like Sieve), where we have access to the
IQueryable
that is being filtered? (that's how we achieved search in our past projects)e.g.
The text was updated successfully, but these errors were encountered: