Guest User

Untitled

a guest
Aug 14th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. var connectionString = "connection string";
  4.  
  5. var url = MongoUrl.Create(connectionString);
  6. var database = new MongoClient(connectionString).GetDatabase(url.DatabaseName);
  7.  
  8. var collection = database.GetCollection<BridgeGameStateDocument>("bridge_games_states");
  9.  
  10. while (true)
  11. {
  12. Console.WriteLine("Enter _id:");
  13.  
  14. var id = Console.ReadLine().Trim();
  15. var filter = new BsonDocument("_id", id);
  16.  
  17. var filter2 = Builders<BridgeGameStateDocument>.Filter.Eq(e => e.Id, id);
  18.  
  19. var doc = collection.Find(filter2).FirstOrDefault();
  20.  
  21. Console.WriteLine("Success " + doc.Id);
  22. }
  23. }
  24.  
  25.  
  26.  
  27. public class BridgeGameStateDocument
  28. {
  29. [BsonId]
  30. public string Id { get; set; }
  31. public string HostUserId { get; set; }
  32.  
  33. public int? CompeteRound { get; set; }
  34.  
  35. [BsonDateTimeOptions(Kind = DateTimeKind.Utc)]
  36. public DateTime Created { get; set; }
  37.  
  38. [BsonDateTimeOptions(Kind = DateTimeKind.Utc)]
  39. public DateTime? Started { get; set; }
  40.  
  41. [BsonDateTimeOptions(Kind = DateTimeKind.Utc)]
  42. public DateTime? Finished { get; set; }
  43. public string Vulnerable { get; set; }
  44. public string DealId { get; set; }
  45.  
  46. [JsonConverter(typeof(StringEnumConverter))]
  47. [BsonRepresentation(BsonType.String)]
  48. public DealTypeEnum GameType { get; set; }
  49.  
  50. [JsonConverter(typeof(StringEnumConverter))]
  51. [BsonRepresentation(BsonType.String)]
  52. public GameMode GameMode { get; set; }
  53. public string HostUserName { get; set; }
  54.  
  55. public long BiddingDealNumber { get; set; }
  56. public string BoardNumber { get; set; }
  57.  
  58. }
  59.  
  60. public enum DealTypeEnum
  61. {
  62. Attack,
  63. Defence,
  64. Bidding,
  65. Compete,
  66. AttackEasy
  67. }
  68.  
  69. public enum GameMode
  70. {
  71. PracticeAttackSets = 1,
  72. Ebook = 16,
  73. Bidding = 32,
  74. Compete = 64,
  75. PlayEasy = 128
  76. }
Add Comment
Please, Sign In to add comment