General.Backend.Shared 4.0.2

dotnet add package General.Backend.Shared --version 4.0.2
                    
NuGet\Install-Package General.Backend.Shared -Version 4.0.2
                    
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="General.Backend.Shared" Version="4.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="General.Backend.Shared" Version="4.0.2" />
                    
Directory.Packages.props
<PackageReference Include="General.Backend.Shared" />
                    
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 General.Backend.Shared --version 4.0.2
                    
#r "nuget: General.Backend.Shared, 4.0.2"
                    
#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 General.Backend.Shared@4.0.2
                    
#: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=General.Backend.Shared&version=4.0.2
                    
Install as a Cake Addin
#tool nuget:?package=General.Backend.Shared&version=4.0.2
                    
Install as a Cake Tool

Generic Architecture

Reusable generic infrastructure for .NET applications using ASP.NET Core and Entity Framework Core.

Features

  • Generic Core abstraction and implementation
  • Generic EF Core repositories
  • CRUD operations
  • Pagination
  • Expression-based filtering
  • Dynamic filtering
  • HTTP QUERY support
  • Generic ASP.NET Core controllers
  • Request/response mapping
  • Resilient outbound HTTP request handling

Architecture

HTTP │ ▼ GenericController │ ▼ IGenericCore │ ▼ IGenericRepository │ ▼ Entity Framework Core │ ▼ Database


For complex queries:

```text
QUERY
 │
 ▼
QueryRequest
 │
 ▼
DynamicFilterExpressionBuilder
 │
 ▼
Expression<Func<TEntity, bool>>
 │
 ▼
IQueryable<TEntity>
 │
 ▼
EF Core

Main Contracts

Contract Responsibility
IGenericCore<TEntity,TResponse,TRequest> Application-level CRUD
IGenericGetRepository<TEntity> Generic read operations
IGenericRepository<TEntity> Generic persistence operations
GenericController<TEntity,TResponse,TRequest> Reusable HTTP CRUD/query endpoints
GenericCore<TEntity,TResponse,TRequest> Reusable Core CRUD/query endpoints and mapping orchestration
GenericGetRepository<TEntity> generic read implementation operations (query)
GenericRepository<TEntity> generic persistence implementation CRUD/query
ResilientRequestHandler Centralized outbound HTTP resilience

Quick Start

Repository

public sealed class ActivityRepository(DbContext context)
    : GenericRepository<Activity>(context), IGenericRepository<Activity>
{
}

Core

public sealed class ActivityCore(IGenericRepository<Activity> repository)
    : GenericCore<Activity, ActivityDto, ActivityCreationDto>(repository)
{
    protected override Activity MapToEntity(ActivityCreationDto source)
    {
        return new Activity
        {
            Description = source.Description,
            TypeActivityId = source.TypeActivityId
        };
    }

    protected override void MapTo(ActivityCreationDto source, Activity destination)
    {
        destination.Description = source.Description;
        destination.TypeActivityId = source.TypeActivityId;
    }

    protected override ActivityDto MapToResponse(Activity source)
    {
        return new ActivityDto
        {
            ActivityId = source.ActivityId,
            Description = source.Description
        };
    }

    protected override IEnumerable<ActivityDto> MapToResponse(IEnumerable<Activity> source)
    {
        ...
    }
}

Controller

[Route("api/[controller]")]
[ApiController]
public sealed class ActivityController(IGenericCore<Activity, ActivityDto, ActivityCreationDto> core)
    : GenericController<Activity, ActivityDto, ActivityCreationDto>(core)
{
}

Endpoints

The generic controller provides:

GET    /api/activity/{id}
GET    /api/activity
QUERY  /api/activity/dynamic-filter
POST   /api/activity
PUT    /api/activity/{id}

Dynamic Query

QUERY /api/activity/dynamic-filter
Content-Type: application/json
{
  "pagination": {
    "page": 1,
    "recordsByPage": 20
  },
  "filter": {
    "fieldFilters": [
      {
        "name": "Description",
        "dataType": "enString",
        "filterOperator": "Contains",
        "values": ["SQL"],
        "logicalFilterOperator": "And"
      }
    ]
  }
}

Query Result

Paginated queries return:

ResponseService<QueryResult<TResponse>>

ResponseService<T> contains the operation result and HTTP metadata.

QueryResult<T> contains:

IEnumerable<T> Records
int TotalRecords

Pagination metadata therefore remains separate from the generic response envelope.

Documentation

Design

The package intentionally separates:

Repository
    Persistence and EF Core

Core
    Application orchestration and mapping

Controller
    HTTP boundary

Entity-specific behavior remains in the consuming application, while repetitive infrastructure is provided by the package.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 (1)

Showing the top 1 NuGet packages that depend on General.Backend.Shared:

Package Downloads
General.Backend.RepositoryPattern

The GenericRepository abstract class implements a generic data repository with the most commonly used methods for creating, updating and retrieving data.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.2 116 8/28/2026
4.0.1 104 8/27/2026
4.0.0 100 8/27/2026
3.0.1 114 8/26/2026
3.0.0 115 8/25/2026
2.0.3 166 8/4/2026
2.0.2 125 7/22/2026
2.0.1 116 7/16/2026
2.0.0 170 7/16/2026
1.1.1 163 4/17/2026
1.1.0 166 4/3/2026
1.0.2 212 2/12/2025
1.0.1 179 1/14/2025
1.0.0 193 1/9/2025

- Replace IMapper dependency with abstract MapToResponse, MapListToResponse, and MapToEntity
methods in GenericCore, removing the AutoMapper package entirely
- Fix bug where GetAllAsync/GetByFilterAsync/GetByDynamicFilterAsync mapped the full tuple
instead of result.PageRecords
- ErrorHandler: prevent internal exception details from leaking to clients; fix structured
logging placeholders; return 400 BadRequest for validation errors instead of 500
- ResilientRequestHandler: set ExceptionsAllowedBeforeBreaking default to 3 (was 0, broke Polly)
- ResponseService: change records default from 1 to 0
- GenericCore.UpdateAsync: fix wrong service name in validation error ("AddAsync" -> "UpdateAsync")
- GenericCore.AddAsync: remove redundant new T() instantiation
- Bump dependencies to .NET 10 targets
- (16/07/2026) Refactor GenericCore to exclude ILogger and ErrorHandler to allow implementation of Global Error Handling and logging in the host project,
and to allow for more flexible dependency injection. Add new static methods to ResponseService to allow for more flexible response handling,
including the ability to return custom responses and status codes.
Delete ErrorHandler class and move its functionality to the host project.
-(17/07/2026) Refactor include cancelation token in all async methods.
-(18/07/2026) Added new IGenericCore interface to implement GenericCore in the host project, allowing for more flexible dependency injection and customization of the core functionality.
-(04/08/2026) Added new static methods to ResponseService to allow for more flexible response handling, including the ability to return custom responses and status codes.
-(25/08/2026) Added MapTo abstract method mapping from request to existing entity.
Added generic repository implementation classes.
Refactored generic repository and Core interfaces.
Introduced QueryResult(T) for query results and total record count.
Refactor ResponseService, Updated paginated API responses to use ResponseService(QueryResult(TResponse)).
-(26/08/2026) Refactor Generic Controller
-(26/08/2026) Decoupling shared elements between the frontend and the backend
-(28/08/2026) Add POST method to replace Query Method