I'm running into a problem deserializing an object that has a property which inherits from iDictionary using the standard C# driver for MongoDB. The error message I'm getting is:
An error occurred while deserializing the cxnProps property of class MyClass: DictionarySerializer<String, String> can't be used with type String.
I set the SetSerializationOptions of the cxnProps object to DictionarySerializationOptions.ArrayOfDocuments (Actually I tried them all) and it seems to serialize into the database without a problem, but I get the error when I'm trying to read it back into the MyClass class using:
var results = myMongoCollection.AsQueryable<MyClass>().Where(e => e.MyId== myclass.MyId).ToArray();
In the database the cxnProps property looks like this:
"CxnProps" : [ { "k" : "thisID", : "123456" } ] } --when using the ArrayOfDocuments representation.
The CxnProps property is an object that looks like this:
public interface CxnCollection: IDictionary<string, string>
{
string UserName { get; set; }
string RedirectURL { get; set; }
}
Why would I be getting this type of error when deserializing?