title: How to serialize dictionary with custom value type for MongoDb?
body: <p>I have the following class, the instances of which I'd like to write to MongoDb:</p>
  
  <pre><code>public class ChartDefinitionBase
  {
      public ChartDefinitionBase(ObjectId id, IDictionary&lt;ISite, IExample&gt; examples)
      {
          ObjectId = id;
          Examples = examples;
      }
  
      [BsonIgnoreIfDefault]
      [BsonId(IdGenerator = typeof(ObjectIdGenerator))]
      public ObjectId ObjectId { get; private set; }
  
      [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfDocuments)]
      public IDictionary&lt;ISite, IExample&gt; Examples{ get; private set; }
  }
  </code></pre>
  
  <p>When I attempt to call '<code>InsertOne()</code>' on an instance of this type, I get the following <code>ArgumentException</code>: </p>
  
  <blockquote>
    <p>GenericArguments[1], 'System.Collections.Generic.List{1}[System.Collections.Generic.KeyValuePair{2}[System.String,System.Object]]', 
    on 'MongoDB.Bson.Serialization.Serializers.ImpliedImplementationInterfaceSerializer{2}[TInterface,TImplementation]' violates the constraint of type 'TImplementation'.</p>
  </blockquote>
  
  <p>If I convert the dictionary value type to a string, for instance, the exception disappears and serialization works great. However if I use a concrete implementation of <code>IExample</code>, I get the same exception.<br>
  How do I go about getting a dictionary with a custom value type to serialize?</p>