Abstraction Layer for multiple Database Technologies.
Currently Supported:
- Local In Memory Database
- Azure Cosmos DB
- MongoDB
Install the NuGet package into your project.
dotnet add package Wemogy.Infrastructure.Database.InMemoryInitialize the Database Client Factory centrally.
var databaseClientFactory = new InMemoryDatabaseClientFactory();Install the NuGet package into your project.
dotnet add package Wemogy.Infrastructure.Database.CosmosInitialize the Database Client Factory centrally.
var databaseClientFactory = new CosmosDatabaseClientFactory("<CONNECTION_STRING>", "<DATABASE_NAME>");Install the NuGet package into your project.
dotnet add package Wemogy.Infrastructure.Database.MongoInitialize the Database Client Factory centrally.
var databaseClientFactory = new MongoDatabaseClientFactory("<CONNECTION_STRING>", "<DATABASE_NAME>");If your Models are stored in a differen class library, install the Core NuGet package into your project.
dotnet add package Wemogy.Infrastructure.Database.CoreDefine a class that you want to store in a database vie the Repository, and let it inherit from EntityBase.
public class Foo : EntityBase
{
}Each repository needs to implement the IDatabaseRepository<T> interface.
public interface IFooRepository : IDatabaseRepository<Foo>
{
}Register the Database Client Factory and the Repositories centrally at the Dependency Injection Container (for example in Startup.cs).
var databaseClientFactory = new // ...
services
.AddDatabase(databaseClientFactory)
.AddRepository<IFooRepository>()
.AddRepository<IBarRepository>();Checkout the full Documentation to get information about the available classes and extensions.
docker compose -f env/cosmos/docker-compose.yaml updocker compose -f env/mongo/docker-compose.yaml up