title: In Mongo custom serialization how do I get the objectId?
body: <p>In Mongo custom serialization how do I get the objectId?</p>
  
  <p>I have implemented IBsonSerializer and my data is showing up in the database the way I want it. However my ObjectId is now empty (000000000000000000000000) after I insert into the collection where before it had the ObjectId like 5236ea9949444a06d7f50012. I can see the ObjectId is in the database so I know it is there, it is just not being populated to my C# object after I insert into the collection.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class EvaluationResultMongoSerializer : IBsonSerializer
  {
  
      public object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
      {
          throw new NotImplementedException();
      }
  
      public object Deserialize(BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options)
      {
          throw new NotImplementedException();
      }
  
      public IBsonSerializationOptions GetDefaultSerializationOptions()
      {
          return null;
      }
  
      public void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
      {
  
          EvaluationResult er = (EvaluationResult)value;
          bsonWriter.WriteStartDocument();
          bsonWriter.WriteDouble("Duration", er.DurationInSeconds);
          bsonWriter.WriteDateTime("Start", BsonUtils.ToMillisecondsSinceEpoch(er.startTime));
          bsonWriter.WriteDateTime("End", BsonUtils.ToMillisecondsSinceEpoch(er.endTime));
          bsonWriter.WriteString("Result", er.Result.ValueAsString);
          bsonWriter.WriteEndDocument();
      }
  }
  </code></pre>
  
  <p>I register the mapping like this:</p>
  
  <pre><code>BsonSerializer.RegisterSerializer(
              typeof(EvaluationResult),
              new EvaluationResultMongoSerializer()
          );
  </code></pre>
  
  <p>and I'm not registering any class maps.</p>