MongoGenericRepository.HealthChecks
9.0.4
dotnet add package MongoGenericRepository.HealthChecks --version 9.0.4
NuGet\Install-Package MongoGenericRepository.HealthChecks -Version 9.0.4
<PackageReference Include="MongoGenericRepository.HealthChecks" Version="9.0.4" />
<PackageVersion Include="MongoGenericRepository.HealthChecks" Version="9.0.4" />
<PackageReference Include="MongoGenericRepository.HealthChecks" />
paket add MongoGenericRepository.HealthChecks --version 9.0.4
#r "nuget: MongoGenericRepository.HealthChecks, 9.0.4"
#:package MongoGenericRepository.HealthChecks@9.0.4
#addin nuget:?package=MongoGenericRepository.HealthChecks&version=9.0.4
#tool nuget:?package=MongoGenericRepository.HealthChecks&version=9.0.4
MongoRepository
Straightforward CRUD repository for MongoDB
The main purpose of MongoRepository is to provide an as easy as possible DAL for services using MongoDB without tinkering. For each entity it will create a collection / table named after the entity.
How to use it
Add your connection string to appsettings.json
{
"MongoDbOptions": {
"ReadWriteConnection": "mongodb://your-readwrite-connectionstring",
"ReadOnlyConnection": "mongodb://your-readonly-connectionstring"
}
}
Then add an entity which implements IEntity<string> which basically means it has an ID field with Bson attributes. By default the entities type name is used as name for the database and the collection as well. If you desire to use a database and/or a collection whose names differ from this you can use the referring attributes.
[EntityDatabase("WeatherForecastDB")]
[EntityCollection("WeatherForecastCollection")]
public class WeatherForecast : IEntity<string>
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
//...
}
For each entity you need a repository which implements IReadWriteRepository<TEntity, string>. It is possible to add your own methods to the repository and of course to override the default ones.
public interface IWeatherForecastRepository : IReadWriteRepository<WeatherForecast, string>
{
Task<IList<WeatherForecast>> GetAllWeatherForecastsWith16Degree();
}
public class WeatherForecastMongoDbRepository : ReadWriteRepository<WeatherForecast, string>, IWeatherForecastRepository
{
public WeatherForecastMongoDbRepository(IOptions<MongoDbOptions> mongoOptions) : base(mongoOptions)
{
}
public async Task<IList<WeatherForecast>> GetAllWeatherForecastsWith16Degree()
{
var filter = Builders<WeatherForecast>.Filter.Eq(nameof(WeatherForecast.TemperatureC), 16);
return await Collection
.Find(filter)
.ToListAsync();
}
}
Last thing to do is to inject your connectionstring and the repository
services.Configure<MongoDbOptions>(Configuration.GetSection("MongoDbOptions"));
services.AddScoped<IWeatherForecastRepository, WeatherForecastRepository>();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. 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 is compatible. 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 6.0.0)
- MongoGenericRepository (= 9.0.4)
-
net6.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 6.0.0)
- MongoGenericRepository (= 9.0.4)
-
net7.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 7.0.0)
- MongoGenericRepository (= 9.0.4)
-
net8.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.0)
- MongoGenericRepository (= 9.0.4)
-
net9.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.9)
- MongoGenericRepository (= 9.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.4 | 261 | 9/10/2025 |