Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tysongibby/genericrepositoryforefcore
Generic repository class for Entity Framework Core
https://github.com/tysongibby/genericrepositoryforefcore
crud csharp-library efcore generic-repository net6
Last synced: 17 days ago
JSON representation
Generic repository class for Entity Framework Core
- Host: GitHub
- URL: https://github.com/tysongibby/genericrepositoryforefcore
- Owner: tysongibby
- License: mit
- Created: 2022-04-17T06:01:15.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-04-16T00:46:27.000Z (over 1 year ago)
- Last Synced: 2024-12-08T09:47:46.299Z (20 days ago)
- Topics: crud, csharp-library, efcore, generic-repository, net6
- Language: C#
- Homepage:
- Size: 349 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Generic Repository for Entity Framework Core - BETA
Generic repository class for Entity Framework Core. "GenericRepository" Can be inherited by any data model repository to instantly add basic functions such as create, read, update, delete, etc..
Create your own interface and have it inherit from "IGenericRepsitory" to use dependency injection and add your own custom function. Then have your repositry inherit your interface after inherting "GenericRepository" See examples below.
Based on .NET 6 and EF Core. *This project is in BETA* - TESTING NOT COMPLETE ON ASYNCHRONOUS METHODS
[Nuget.org page](https://www.nuget.org/packages/GenericRepositoryForEfCore/1.0.0.5-beta)
Nuget package install:
```
dotnet add package GenericRepositoryForEfCore
```
Example implementation:```
using Demo.UltiLuvData.Repositories.Interfaces;
using Demo.UltiLuvData.DataModels;
using GenericRepositoryForEfCore;namespace Demo.UltiLuvData.Repositories
{
public class DemoRepository : GenericRepository, IDemoModelRepository
{
public DemoRepository(ApplicationDbContext context) : base(context) { }
public ApplicationDbContext ApplicationContext
{
get
{
return _context as ApplicationDbContext;
}
}
// add additional functionality here you stubbed in and inherited from your interface
}
}
```
```
using Demo.UltiLuvData.DataModels;
using GenericRepositoryForEfCore.Interfaces;
using System.Threading.Tasks;namespace Demo.UltiLuvData.Repositories.Interfaces
{
public interface IDemoModelRepository : IGenericRepository
{
// stub additional functionality here to be inherited by your repository
}
}
```