Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DummyClass
- {
- [BsonId]
- public int Id { set; get; }
- [BsonElement("first")]
- public string First { set { _name = value; } }
- [BsonConstructor]
- public DummyClass()
- {
- Id = 2;
- First = "1";
- }
- }
- _dbClient = new MongoClient();
- _database = _dbClient.GetDatabase("testDB");
- _collection = _database.GetCollection<BsonDocument>("Collection");
- var doc = BsonDocument.Create(dummy);
- _collection.InsertOneAsync(doc);
- System.ArgumentException : .NET type DummyClass cannot be mapped to BsonType.Document.
- Parameter name: value
- {
- {"Id", "2"},
- {"First", "1"},
- }
- BsonClassMap.RegisterClassMap<DummyClass>();
- _collection = _database.GetCollection<DummyClass>("Collection");
- await _collection.InsertOneAsync(doc);
- _collection.InsertOneAsync(doc.ToBsonDocument())
Add Comment
Please, Sign In to add comment