MSHelper.Persistence.MongoDB
1.0.0
dotnet add package MSHelper.Persistence.MongoDB --version 1.0.0
NuGet\Install-Package MSHelper.Persistence.MongoDB -Version 1.0.0
<PackageReference Include="MSHelper.Persistence.MongoDB" Version="1.0.0" />
paket add MSHelper.Persistence.MongoDB --version 1.0.0
#r "nuget: MSHelper.Persistence.MongoDB, 1.0.0"
// Install MSHelper.Persistence.MongoDB as a Cake Addin #addin nuget:?package=MSHelper.Persistence.MongoDB&version=1.0.0 // Install MSHelper.Persistence.MongoDB as a Cake Tool #tool nuget:?package=MSHelper.Persistence.MongoDB&version=1.0.0
MSHelper.Persistence.MongoDB : Adds the set of conventions and ease of use for MongoDB integration with .NET Core.
⭐ Star us on GitHub � it motivates us a lot!
Overview
Adds the set of conventions and ease of use for MongoDB integration with .NET Core.
Installation
This document is for the latest MSHelper.Persistence.MongoDB 1.0.0 release and later.
dotnet add package MSHelper.Persistence.MongoDB
Dependencies
-- MSHelper
Usage
Extend IMSHelperBuilder
with AddMongo()
that will register the required services.
public static IMSHelperBuilder RegisterMSHelper(this IMSHelperBuilder builder)
{
builder.AddMongo();
// Other services.
return builder;
}
public class SomeService
{
private readonly IMongoDatabase _database;
public SomeService(IMongoDatabase database)
{
_database = database;
}
}
In order to use IMongoRepository
abstraction, invoke AddMongoRepository<TDocument, TIdentifiable>("collectionName")
for each document that you would like to be able to access with this repository abstraction and ensure that document type implements IIdentifiable
interface.
By using the provided IMongoRepository
you can access helper methods such as AddAsync()
, BrowseAsync()
etc. instead of relying on IMongoDatabase
abstraction available via MongoDB.Driver.
Options
--- connectionString - connection string e.g. mongodb://localhost:27017.
--- database - database name.
--- seed - boolean value, if true then IMongoDbSeeder.SeedAsync()
will be invoked (if implemented).
appsettings.json
"mongo": {
"connectionString": "mongodb://localhost:27017",
"database": "some-service",
"seed": false
}
Important Note:
All the MSHelper packages are for self learning purposes inspired by Devmentors.io
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- MongoDB.Driver (>= 2.18.0)
- MSHelper (>= 1.0.0)
- MSHelper.CQRS.Queries (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MSHelper.Persistence.MongoDB:
Package | Downloads |
---|---|
MSHelper.MessageBrokers.Outbox.Mongo
MSHelper.MessageBrokers.Outbox.Mongo - Outbox integration with Mongo DB. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 225 | 10/28/2022 |