This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | services.AddSingleton<IMongoClient>(new MongoClient(Configuration.GetConnectionString("MongoDB"))); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | "ConnectionStrings": {"MongoDB": "mongodb+srv://<user>:<password>@test.fd2ej.mongodb.net/mongo_test?retryWrites=true&w=majority"} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class RestaurantsRepository : IRestaurantsRepository | |
| { | |
| private readonly IMongoCollection<Restaurant> collection; | |
| public RestaurantsRepository(IMongoClient mongoClient, IOptions<DbSettings> options) | |
| { | |
| collection = mongoClient.GetDatabase(options.Value.DatabaseName) | |
| .GetCollection<Restaurant>(options.Value.CollectionName); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class Restaurant | |
| { | |
| public string Id { get; set; } | |
| public string Borough { get; set; } | |
| public string Cuisine { get; set; } | |
| public string Name { get; set; } | |
| public string RestaurantId { get; set; } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var pack = new ConventionPack(); | |
| pack.Add(new CamelCaseElementNameConvention()); | |
| ConventionRegistry.Register("Custom Convention", pack, t => t.FullName.StartsWith("MongoTest")); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | BsonClassMap.RegisterClassMap<Restaurant>(opt => | |
| { | |
| opt.AutoMap(); | |
| opt.GetMemberMap(c => c.RestaurantId).SetElementName("restaurant_id"); | |
| opt.GetMemberMap(c => c.Id).SetSerializer(new StringSerializer(BsonType.ObjectId)); | |
| opt.SetIgnoreExtraElements(true); | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | BsonClassMap.RegisterClassMap<Restaurant>(opt => | |
| { | |
| opt.AutoMap(); | |
| opt.GetMemberMap(c => c.RestaurantId).SetElementName("restaurant_id"); | |
| opt.GetMemberMap(c => c.Id).SetSerializer(new StringSerializer(BsonType.ObjectId)); | |
| opt.SetIgnoreExtraElements(true); | |
| }); |