I have a class in C#, something like:
public class MyEntry
{
public ObjectId Id { get; set; }
public string SimpleHash { get; set; }
public string GroupIdentifier { get; set; }
}
now saving this in mongo works as it should. Now I'd like to add some sub-documents to this document. The sub-document's class looks like this:
public class Detail
{
public DateTime CreateDate { get; set; }
public string DetailHash { get; set; }
}
I add those details to the root documents with the Push-command, like this:
collection.Update(query, Update.PushWrapped("Details", detail));
This works good so far and I have the possibility to read the MyEntry
without all attached Details
and I can read all/the first/the last/whichever Details
I want.
But my problem now is that if I change something in an MyEntry
and save it, the Details
-Array is completely deleted.
Is there a way to leave fields not mentioned in a class alone when updating?