Replies: 2 comments 3 replies
This comment has been hidden.
This comment has been hidden.
-
Hello @ameckl, var dataSource = new List<Test>()
{
new() { Id = 1, MyDictionary = new() { { "Key1", "Value1" }, { "Key2", "Value2" } } },
new() { Id = 2, MyDictionary = new() { { "Key3", "Value1" }, { "Key4", "Value2" } } },
new() { Id = 3, MyDictionary = new() { { "Key5", "Value3" }, { "Key6", "Value4" } } },
}.AsQueryable();
var qb = new QueryBuilder<Test>()
.AddMap("prop", (target, key) => target.MyDictionary[key])
.AddCondition("prop[Key4] = Value2");
qb.Build(dataSource).Select(q => q.Id).Dump(); // returns Id 2
class Test
{
public int Id { get; set; }
public Dictionary<string,string> MyDictionary{ get; set; }
} I'm currently evaluating this feature, but in the meantime, your feedback would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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.
Beta Was this translation helpful? Give feedback.
All reactions