Info
Version: | 7.219.21 |
Author(s): | bl([email protected]) |
Last Update: | Friday, June 2, 2023 |
.NET Fiddle: | Create the first Fiddle |
Project Url: | https://github.com/bailei1987/dotnet |
NuGet Url: | https://www.nuget.org/packages/bl.mongodb |
Install
Install-Package bl.mongodb
dotnet add package bl.mongodb
paket add bl.mongodb
bl.mongodb Download (Unzip the "nupkg" after downloading)
Dependencies
- MongoDB.Driver(>= 2.11.4)
1.BaseDbContext.cs:you can create your DbContext inherit BaseDbContext
package some useful mongodb-to-C# mapping,like ObjectId<=>string,UTC<=>LocalTime,Enum<=>string,property name to camel field..etc
2.can get ConnetionString from env "CONNECTIONSTRINGS_MONGO" in docker container or "ConnectionStrings.Mongo" in appsettings.json:
3.BsonDocumentExtends.cs:
extend method to BsonValue,for example: var bs={info:{gender:{k:'01',v:'Man'}}} .
we can get "Man" through bs.GetValueByHierarchicalNames("info.gender.v")
4.you can simply using BL.MongoDB.Gen's AddBLMongoDbContext method in ConfigureServices(startup.cs) to create your DbContext
5.example.api have some simple code for refering.