|
In your general purpose UpdateObject method you are serializing your TestDictionary property without providing any information about the expected type (what the driver calls nominalType), so the serialized form therefore has a "_t" property to identify the type. However, that's not how it gets serialized when the entire class gets serialized, so you end up with mismatched representations.
The easiest way to get all the element names and serialized representations right is to use the typed builders. For example, you could reimplement your UpdateObject method as:
private static bool UpdateObject<TDocument, TId, TField>(Expression<Func<TDocument, TId>> idLambda, TId id, Expression<Func<TDocument, TField>> fieldLambda, TField value)
|
{
|
var query = Query<TDocument>.EQ(idLambda, id);
|
var update = Update<TDocument>.Set(fieldLambda, value);
|
var result = m_Collection.Update(query, update);
|
return result.UpdatedExisting;
|
}
|
and the call it like this:
var updatedSuccessfully = UpdateObject((TestObject t) => t.Id, testObject.Id, (TestObject t) => t.TestDictionary, testObject.TestDictionary);
|
and then the driver would use all the available type information to generate the right query and update operations (including serializing your updated TestDictionary value in the proper form).
|