I developed a simple API that allows you to create an array of search criteria in the MongoDB collection. Now I should be able to convert this array into a real Mongo Query, and this part is where I am experiencing extreme difficulties.
Ideally, I get some syntax that will allow me to make the following pseudo-code:
var query = new QueryBuilder(); foreach (var group in groups) { switch (group.Condition) { case GroupCondition.Or: query.Or(group.Queries); break; case GroupCondition.And: query.And(group.Queries); break; } } return myCollection.FindAs(type, query);
Actually, I want to create somewhat more complex queries, but in the end, after functionality, I dynamically build up my queries with objects, as shown in my pseudo-code above.
Feel free to ask me for additional details if I have not given myself a clear idea of ββwhat I am trying to achieve.
c # mongodb
JustinN
source share