I create simple class:
public class User
{
// [BsonRepresentation(BsonType.ObjectId)]
public ObjectId _id { get; set; }
[BsonRepresentation(BsonType.String)]
public String Name { get; set; }
[BsonRepresentation(BsonType.String)]
public string Email { get; set; }
}
And then i try to get users collection:
using (var cursor = await col.Find<User>(Builders<User>.Filter.Empty).ToCursorAsync())
{
while (cursor.MoveNext())
{
//do work
}
}
So, it thows exception:"Cannot deserialize a 'ObjectId' from BsonType 'Int32'" at line "ToCursorAsync()".
What i am doing wrong?