"An error occurred while deserializing the Property1 property of class Class1: ReadString can only be called when CurrentBsonType is String, not when CurrentBsonType is ObjectId."
I put the bsonid on the string guid of the class and mapped the class and serialized it, but it is giving me this error when I tried to deserialize my object back to the class from a bsondocument.
How should I fix this?
public class Class1
{
[BsonId]
public string ClassGuid { get; private set; }
}
Then map the class:
if (!BsonClassMap.IsClassMapRegistered(typeof(WordOntology)))
{
BsonClassMap.RegisterClassMap<WordOntology>();
}
Then deserialize
MongoCursor<Class1> _returnResults = _collection.FindAs<Class1>(_query);
Then loop:
foreach(BsonDocument _document in _returnResults)
{
//exception here
}