Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-97

Deserializing a BsonDocument to .net object should not throw FormatException if the document has extra properties.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.7
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      VS 2k8 Win7

      If I have a bson document with keys that do not map to properties in a .net object I am deserializing to, a FormatException is thrown. While I am returning more info than necessary over the wire (doing the mongo equivalent of SELECT * ) I think the code should still function.

      at MongoDB.Bson.DefaultSerializer.BsonClassMapSerializer.DeserializeDocument(BsonReader bsonReader, Type nominalType) in D:\justin's projects\mongo-csharp\Bson\DefaultSerializer\BsonClassMapSerializer.cs:line 83
      at MongoDB.Bson.Serialization.BsonSerializer.DeserializeDocument(BsonReader bsonReader, Type nominalType) in D:\justin's projects\mongo-csharp\Bson\Serialization\BsonSerializer.cs:line 69
      at MongoDB.Bson.Serialization.BsonSerializer.DeserializeDocument[T](BsonReader bsonReader) in D:\justin's projects\mongo-csharp\Bson\Serialization\BsonSerializer.cs:line 45
      at MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(BsonBuffer buffer) in D:\justin's projects\mongo-csharp\Driver\Internal\MongoReplyMessage.cs:line 88
      at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument]() in D:\justin's projects\mongo-csharp\Driver\Internal\MongoConnection.cs:line 291
      at MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.GetReply(MongoRequestMessage message) in D:\justin's projects\mongo-csharp\Driver\Core\MongoCursor.cs:line 477
      at MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.GetFirst() in D:\justin's projects\mongo-csharp\Driver\Core\MongoCursor.cs:line 442
      at MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.MoveNext() in D:\justin's projects\mongo-csharp\Driver\Core\MongoCursor.cs:line 369
      at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
      at MongoDB.Driver.MongoCollection.FindOneAs[TQuery,TDocument](TQuery query) in D:\justin's projects\mongo-csharp\Driver\Core\MongoCollection.cs:line 292
      at MongoDB.Driver.MongoCollection.FindOneAs[TDocument](IBsonSerializable query) in D:\justin's projects\mongo-csharp\Driver\Core\MongoCollection.cs:line 286
      at BEGIN MY COMPANIES CODE

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            zippy1981 Justin Dearing
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: