Reputation: 498
So I searched whole morning but couldn't find satisfactory answer
I am trying to write a generic method (service) which take an object as an input (can be JObject or Document or dynamic) and queries the collection for the properties in the object.
Example - if you send {"name": "abc"} I will search for name="abc" in any of the documents. if you send {"name":"abc", "department":"xyz"}, it searches on both fields.
Question - what should be the best input for the method? Options - 1. public bool Exists(Document doc) //assume I already have Collection.Selflink the class. I cannot seem to iterate through properties of the doc object.
Is there any easier way to just see if the doc matches any of the documents in the collection. I am just interested in matching those fields present in the document.
Thanks in advance!
Upvotes: 6
Views: 806
Reputation: 2728
This isn't supported out of the box.
I would imagine a bit of custom code that iterated over the object passed in and appended each property to a where clause in SQL or Linq would likely solve the problem.
It could start to get messy with nested objects and arrays though.
If this is something you would like to see supported natively, please vote for it http://feedback.azure.com
Upvotes: 4