https://github.com/wemogy/libs-infrastructure-database
Abstraction Layer for multiple Database Technologies.
https://github.com/wemogy/libs-infrastructure-database
cosmosdb database dotnet mongodb
Last synced: 6 months ago
JSON representation
Abstraction Layer for multiple Database Technologies.
- Host: GitHub
- URL: https://github.com/wemogy/libs-infrastructure-database
- Owner: wemogy
- License: mit
- Created: 2022-08-22T15:04:43.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-08-16T19:54:36.000Z (11 months ago)
- Last Synced: 2025-11-16T15:25:47.188Z (8 months ago)
- Topics: cosmosdb, database, dotnet, mongodb
- Language: C#
- Homepage: http://libs-infrastructure-database.docs.wemogy.com/
- Size: 3.59 MB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#  Infrastructure Database Layer
Abstraction Layer for multiple Database Technologies.
Currently Supported:
- Local In Memory Database
- Azure Cosmos DB
- MongoDB
## Getting started
### Local In Memory Database
Install the [NuGet package](https://www.nuget.org/packages/Wemogy.Infrastructure.Database.InMemory) into your project.
```bash
dotnet add package Wemogy.Infrastructure.Database.InMemory
```
Initialize the Database Client Factory centrally.
```csharp
var databaseClientFactory = new InMemoryDatabaseClientFactory();
```
### Azure Cosmos DB
Install the [NuGet package](https://www.nuget.org/packages/Wemogy.Infrastructure.Database.Cosmos) into your project.
```bash
dotnet add package Wemogy.Infrastructure.Database.Cosmos
```
Initialize the Database Client Factory centrally.
```csharp
var databaseClientFactory = new CosmosDatabaseClientFactory("", "");
```
### MongoDB
Install the [NuGet package](https://www.nuget.org/packages/Wemogy.Infrastructure.Database.Mongo) into your project.
```bash
dotnet add package Wemogy.Infrastructure.Database.Mongo
```
Initialize the Database Client Factory centrally.
```csharp
var databaseClientFactory = new MongoDatabaseClientFactory("", "");
```
## Define and register Repositories
If your Models are stored in a differen class library, install the Core [NuGet package](https://www.nuget.org/packages/Wemogy.Infrastructure.Database.Core) into your project.
```bash
dotnet 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`.
```csharp
public class Foo : EntityBase
{
}
```
Each repository needs to implement the `IDatabaseRepository` interface.
```csharp
public interface IFooRepository : IDatabaseRepository
{
}
```
Register the Database Client Factory and the Repositories centrally at the Dependency Injection Container (for example in `Startup.cs`).
```csharp
var databaseClientFactory = new // ...
services
.AddDatabase(databaseClientFactory)
.AddRepository()
.AddRepository();
```
---
Checkout the full [Documentation](http://libs-infrastructure-database.docs.wemogy.com/) to get information about the available classes and extensions.
## Testing
### Cosmos
#### Initialize & start the cosmos DB emulator
```bash
docker compose -f env/cosmos/docker-compose.yaml up
```
### MongoDB
#### Initialize & start the MongoDB emulator
```bash
docker compose -f env/mongo/docker-compose.yaml up
```