AppComponents.Repository 1.0.0

dotnet add package AppComponents.Repository --version 1.0.0
                    
NuGet\Install-Package AppComponents.Repository -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AppComponents.Repository" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AppComponents.Repository" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AppComponents.Repository" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AppComponents.Repository --version 1.0.0
                    
#r "nuget: AppComponents.Repository, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AppComponents.Repository@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AppComponents.Repository&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AppComponents.Repository&version=1.0.0
                    
Install as a Cake Tool

AppComponents.Repository

A generic repository pattern implementation for Entity Framework Core.

Installation

Install via NuGet Package Manager:

Install-Package AppComponents.Repository

Or via .NET CLI:

dotnet add package AppComponents.Repository

Features

  • Generic repository pattern for Entity Framework Core.
  • Supports CRUD operations.
  • Query filtering, ordering, and pagination.
  • Integration with dependency injection.

Usage

Register Repository in Dependency Injection

using AppComponents.Repository.EFCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddDbContext<MyDbContext>(options => options.UseSqlServer("your_connection_string"));
services.AddRepository<MyEntity, MyDbContext>();

Define Your DbContext and Entity

public class MyDbContext : DbContext
{
    public MyDbContext(DbContextOptions<MyDbContext> options) : base(options) {}
    public DbSet<MyEntity> MyEntities { get; set; }
}

public class MyEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
}

Using the Repository

using AppComponents.Repository.Abstraction;

public class MyService
{
    private readonly IRepository<MyEntity, MyDbContext> _repository;
    
    public MyService(IRepository<MyEntity, MyDbContext> repository)
    {
        _repository = repository;
    }

    public async Task AddEntityAsync()
    {
        var entity = new MyEntity { Name = "Sample Entity" };
        await _repository.AddAsync(entity);
    }

    public async Task<List<MyEntity>> GetEntitiesAsync()
    {
        return await _repository.GetAllAsync();
    }
}

Pagination Support

var pagination = new Pagination(pageIndex: 1, pageSize: 10);
var pagedResults = await _repository.GetAllAsync(paginationSpec: pagination);

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 180 2/25/2025