Open hum-bug opened 7 years ago
@mkolt : Can you help here?
You need to pass 2nd parameter as object and not string, as the sproc expects an object. Try something like this:
var spParams = new object[2] { docID, JObject.Parse(@"$addToSet: {arrayname: {foo1:\""bar1\"", foo2:\""bar2\""}") };
That was the issue.
For anyone reading this with similar issue - I tested using the following:
var spParams = new object[2] { docID, JObject.Parse(@"{""$addToSet"": {""arrayname"": {""foo1"":""bar1"", ""foo2"":""bar2""}}}") };
I also added using Newtonsoft.Json.Linq;
Make sense now I know how. As you said I was expecting to pass a JSON string so will plan out using a model.
Appreciate the quick response - thanks.
Hi,
I'm trying to use the stored procedure update.js from a c# .NET client using the following:
It seems to run without error but just returns the original document - no changes.
I'm not sure I'm submitting the correct structure but when I test this in the portal it runs correctly but again, no changes made to the data in the document. Just the original document returned.
["5b22f104-a943-98f9-14dd-947e79a17480","$addToSet: {arrayname: {foo1:\"bar1\",foo2:\"bar2\"}"]
I also tried a more simple $set but see same issues.
Is there any .NET examples for using $addToSet in update.js?
Thanks