Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.
/ IRepository Public archive

Interface for generic repository implementation

License

Notifications You must be signed in to change notification settings

ukad-group/IRepository

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IRepository

A generic repository interface for .NET applications implementing the repository pattern.

Features

  • Generic IRepository<TEntity> interface for data access abstraction
  • Async/await support with CancellationToken
  • LINQ-based querying with IQueryable<T>
  • Extension methods for pagination and common operations
  • No-tracking queries for read-only scenarios

Installation

dotnet add package UkadGroup.IRepository

Or via NuGet Package Manager:

Install-Package UkadGroup.IRepository

Usage

Implement the interface for your data access layer:

public class EfRepository<TEntity> : IRepository<TEntity> where TEntity : class
{
    private readonly DbContext _context;

    public IQueryable<TEntity> GetAll() => _context.Set<TEntity>();

    public async Task<TEntity> GetByIdAsync(int id, CancellationToken ct = default)
        => await _context.Set<TEntity>().FindAsync(new object[] { id }, ct);

    // ... implement other methods
}

Use with dependency injection:

services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));

Interface Methods

Method Description
GetAll() Returns all entities as queryable
GetAllAsNoTracking() Returns entities without change tracking
GetByIdAsync() Finds entity by ID
AddAsync() Adds new entity
Update() Updates existing entity
Delete() Removes entity
SaveChangesAsync() Persists changes

Downloads

NuGet

License

MIT License - see LICENSE for details.

Support and Engineering Services

UKAD provides engineering support for teams that need help with solution design, integration or long term development. If you want to extend this project or need expertise in .NET, React, Azure, AI, Umbraco or Optimizely, you can contact us at hi@ukad-group.com.

About

Interface for generic repository implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages