Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 55 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. public class DummyClass
  2. {
  3.     [BsonId]        
  4.     public int Id { set; get; }
  5.  
  6.     [BsonElement("first")]
  7.     public string First { set { _name = value; } }
  8.  
  9.     [BsonConstructor]
  10.     public DummyClass()
  11.     {
  12.         Id = 2;
  13.         First = "1";
  14.     }
  15. }
  16.    
  17. _dbClient = new MongoClient();
  18. _database = _dbClient.GetDatabase("testDB");
  19. _collection = _database.GetCollection<BsonDocument>("Collection");
  20.  
  21. var doc = BsonDocument.Create(dummy);
  22. _collection.InsertOneAsync(doc);
  23.    
  24. System.ArgumentException : .NET type DummyClass cannot be mapped to BsonType.Document.
  25. Parameter name: value
  26.    
  27. {
  28.     {"Id", "2"},
  29.     {"First", "1"},
  30. }
  31.    
  32. BsonClassMap.RegisterClassMap<DummyClass>();
  33.    
  34. _collection = _database.GetCollection<DummyClass>("Collection");
  35. await _collection.InsertOneAsync(doc);
  36.    
  37. _collection.InsertOneAsync(doc.ToBsonDocument())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top