Mongo Experts!
I need your help to figure out what I can do to get my updates to succeed. Please see my problem below (excerpt from my StackOverflow question):
QUESTION:
I'm using the latest MongoDB-C# Driver in an ASP.NET MVC WebAPI controller.
I do not receive an error when I call:
collection.Update(Query<T>.EQ(e => e.Id, entity.Id),
MongoDB.Driver.Builders.Update<T>.Replace(entity), WriteConcern.Acknowledged)But the reported number of documents affected is 0.
If I run a UnitTest directly against the controller (ie. It's not hosted or running under any server. Just treating it like a normal class by instantiating the controller in my UnitTest) when I do this then everything works as expected.
So I only have this issue while my site is hosted.
MORE: If I create a new object and then try to modify that created object and call the above code than the update succeeds.
Example: If I call Post on my WebAPI controller to create an object which runs this code:
MongoConnection.Collection.Insert(value, WriteConcern.Acknowledged)And then I modify that object and call Post on my WebAPI controller which runs the first block of code:
collection.Update(Query<T>.EQ(e => e.Id, entity.Id),
MongoDB.Driver.Builders.Update<T>.Replace(entity), WriteConcern.Acknowledged)Then the update succeeds.
Am I doing something wrong? Any ideas for figuring out what the actual failure is? Is there a way to debug the calls to MongoDB?
One more piece of information. We are using MongoLab in Azure to host our MongoDB repo.
Thanks in advanced for the help!
-Danny