The purpose of this project is to provide a .NET library for integrating the service/repository pattern into a MongoDB database connection. This document serves as a guide to the key aspects of the project and how to use it properly.
The service/repository pattern is widely used in the programming world, allowing a clear separation between the data access layer and the business logic layer. This article explains the concept clearly and concisely.
This project aims to serve as both a starting point for applications and a valuable educational resource. It provides a clear representation and practical use of the pattern.
The project has been developed with a strong focus on adhering to SOLID principles, structuring the code to ensure clarity, readability, maintainability, and extensibility over time. Great attention has also been paid to code cleanliness through tools like StyleCop, which ensures consistency and adherence to C# coding conventions.
The authors of this project strongly believe in these principles as the foundation for producing quality software.
Clone the repository.
git clone https://github.com/defra91/.NET-Mongorize.git
Navigate to the Dockerfile for the compilation of the build image for the library.
cd src
Build the Docker image based on the located docker file.
docker build -t dotnet-mongorize-compiler-image .
Run the Docker container based on the compiled image.
docker run --name dotnet-mongorize-compiler-container dotnet-mongorize-compiler-image
Inside the Demo
folder, you can find an example project that showcases how to use all the features of the Mongorize library, starting with well-defined sample entities.
Navigate to the demo folder.
cd .NET-mongorize/demo
Compile the demo project.
dotnet build
Create the appsettings.json
file containing the mongo db configuration and place it inside the compiled demo project location (.NET-mongorize/demo/bin/Debug/net8.0/appsettings.json
).
here an example:
{
"MongoSettings": {
"Connection": "mongodb://localhost:27017",
"DatabaseName": "my-awesome-database",
"LogQueries": true
}
}
Run the demo project.
dotnet run
The project provides a Dockerfile
, which is responsible for building the image used to compile the library. The image's sole purpose is to compile the library, so it can be integrated into a continuous integration pipeline.
On the folder test
you will find the collection of all the unit tests that have been written for the library.