title: MongoDb C# driver, property of type implementing IList not saving
body: <p>Changed the persistence layer of my web app to MongoDb using the C# drivers from the MongoDb site. Was pleasantly surprised to find all of my tests passing... except for one class. One of its properties is a type that implements IList and for some reason it doesn't save its items. </p>
  
  <p>I've built a minimal test case to illustrate. Here's the test code to create and save the parent object:</p>
  
  <pre><code>var fooCollection = database.GetCollection&lt;Foo&gt;( typeof( Foo ).Name );
  var foo = new Foo {Id = "Root"};
  foo.Foos.Add( new Foo{ Id = "Child" } );
  fooCollection.Save( foo );
  </code></pre>
  
  <p>If I declare Foo.Foos as being <code>List&lt;Foo></code> it works:</p>
  
  <pre><code>public class Foo {
    public Foo() {
      Foos = new List&lt;Foo&gt;();
    }
    public List&lt;Foo&gt; Foos;
    public string Id;
  }  
  </code></pre>
  
  <p>The (correct) result:</p>
  
  <pre><code>{ "_id" : "root", "Foos" : [ { "Foos" : [], "_id" : "child" } ] }
  </code></pre>
  
  <p>However what I need is this:</p>
  
  <pre><code>public class Foo {
    public Foo() {
      Foos = new FooList();
    }
    public FooList Foos;
    public string Id;
  }
  
  public class FooList : IList&lt;Foo&gt; {
     //IList implementation omitted for brevity
  }
  </code></pre>
  
  <p>The (incorrect) result is:</p>
  
  <pre><code>{ "_id" : "root", "Foos" : { "Capacity" : 4 } }
  </code></pre>
  
  <p>Note that it has nothing to do with my IList implementation as the results are the same if I use <code>FooList : List&lt;Foo></code>. </p>
  
  <p>I'm presuming that the BSON serializer is getting confused? I looked at the documentation on discriminators, which led me to think that this might help:</p>
  
  <pre><code>BsonClassMap.RegisterClassMap&lt;List&lt;Foo&gt;&gt;( cm =&gt; {
    cm.AutoMap();
    cm.SetIsRootClass( true );
  } );
  BsonClassMap.RegisterClassMap&lt;FooList&gt;();    
  </code></pre>
  
  <p>I still don't get my items saved though, ends up looking like this:</p>
  
  <pre><code>{ "_id" : "root", "Foos" : { "_t" : [ "List`1", "FooList" ], "Capacity" : 4 } }
  </code></pre>
  
  <p>How can I save <code>FooList</code> correctly?</p>