Abstraction Layer for multiple Database Technologies.
Currently Supported:
- Local In Memory Database
- Azure Cosmos DB
- MongoDB
Install the NuGet package into your project.
dontet add package Wemogy.Infrastructure.Database.Cosmos
Initialize the Database Client Factory centrally.
var databaseClientFactory = new InMemoryDatabaseClientFactory();
Install the NuGet package into your project.
dontet add package Wemogy.Infrastructure.Database.InMemory
Initialize the Database Client Factory centrally.
var databaseClientFactory = new CosmosDatabaseClientFactory("<CONNECTION_STRING>", "<DATABASE_NAME>");
Install the NuGet package into your project.
dontet add package Wemogy.Infrastructure.Database.Mongo
Initialize 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.
dontet add package Wemogy.Infrastructure.Database.Core
Define 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 up
docker compose -f env/mongo/docker-compose.yaml up