RepositoryKit.MongoDB
9.0.2
See the version list below for details.
dotnet add package RepositoryKit.MongoDB --version 9.0.2
NuGet\Install-Package RepositoryKit.MongoDB -Version 9.0.2
<PackageReference Include="RepositoryKit.MongoDB" Version="9.0.2" />
<PackageVersion Include="RepositoryKit.MongoDB" Version="9.0.2" />
<PackageReference Include="RepositoryKit.MongoDB" />
paket add RepositoryKit.MongoDB --version 9.0.2
#r "nuget: RepositoryKit.MongoDB, 9.0.2"
#:package RepositoryKit.MongoDB@9.0.2
#addin nuget:?package=RepositoryKit.MongoDB&version=9.0.2
#tool nuget:?package=RepositoryKit.MongoDB&version=9.0.2
<div align="center"> <img src="logo-64x64.png" width="120" alt="RepositoryKit logo" />
RepositoryKit.MongoDB
MongoDB Driver Implementation for RepositoryKit
</div>
📦 Package
Provides a repository implementation using MongoDB.Driver. It supports flexible querying and follows the same interface contract as EF version.
✨ Features
MongoRepository<T, TKey>
implements all core contracts- Async-first design
- Supports filtering, sorting, and paging
- Clean integration with MongoDB collections
🧰 Usage
services.Configure<MongoDbOptions>(Configuration.GetSection("MongoDb"));
services.AddSingleton<IMongoClient>(sp =>
{
var options = sp.GetRequiredService<IOptions<MongoDbOptions>>().Value;
return new MongoClient(options.ConnectionString);
});
services.AddScoped<IMongoDatabase>(sp =>
{
var options = sp.GetRequiredService<IOptions<MongoDbOptions>>().Value;
return sp.GetRequiredService<IMongoClient>().GetDatabase(options.Database);
});
services.AddScoped(typeof(IRepository<,>), typeof(MongoRepository<,>));
🔍 Example
// appsettings.json
"MongoDb": {
"ConnectionString": "mongodb://localhost:27017",
"Database": "RepositoryKitDb"
}
// Define your entity
public class Product
{
public Guid Id { get; set; }
public string Name { get; set; }
}
// Injected service
private readonly IRepository<Product, Guid> _repo;
public ProductService(IRepository<Product, Guid> repo)
{
_repo = repo;
}
// Usage
await _repo.AddAsync(new Product { Id = Guid.NewGuid(), Name = "Pen" });
📁 Requirements
- MongoDB.Driver
- Microsoft.Extensions.Options
📜 License
MIT © Ataberk Kaya
📎 This package depends on
RepositoryKit.Core
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net9.0
- MongoDB.Driver (>= 3.4.0)
- RepositoryKit.Core (>= 9.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RepositoryKit.MongoDB:
Package | Downloads |
---|---|
RepositoryKit
Umbrella package for RepositoryKit - a modular repository pattern infrastructure that supports EF Core, MongoDB and clean LINQ extensions. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial stable version for MongoDB repositories compatible with .NET 9.