Skip to content

dimesoftware/repository

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

Repositories

Implementation of the repository pattern with Entity Framework.

About this project

Generic repository pattern with an implementation using Entity Framework. This project revolves around the IRepository<T> interface. This interfaces defines the capabilities of a repository which - rather unsurprisingly - are simple CRUD operations.

In addition, this project is also concerned with instantiating the repositories. Rather than accessing the repository's implementation directly, a repository factory (defined by IRepositoryFactory) can be used and injected into the application.

The projects in the Providers folder provide the implementation of the contracts defined in the Dime.Repositories assembly.

Getting started

Use the package manager NuGet to install Dime.Repositories:

dotnet add package Dime.Repositories

Usage

Here's a simple example which demonstrates the usage of the repository.

using Dime.Repositories;

public class CustomerService
{
  private readonly IRepository<Customer> _repository;
  public CustomerService(IRepository<Customer> repository)
  {
    _repository = repository;
  }

  public async IEnumerable<Customer> GetCustomers()
    => await _repository_.FindAllAsync(x => x.IsActive == true);
}

Build and Test

To run the solution, you will need:

  • You must have Visual Studio 2022 Community or higher.
  • The dotnet cli is also highly recommended.

To run the tests, you can use the trustee dotnet cli commands:

  • Run dotnet restore
  • Run dotnet build
  • Run dotnet test

Contributing

PRs Welcome

Pull requests are welcome. Please check out the contribution and code of conduct guidelines.

License

License