RGHB.DBCommons 1.6.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package RGHB.DBCommons --version 1.6.0
                    
NuGet\Install-Package RGHB.DBCommons -Version 1.6.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="RGHB.DBCommons" Version="1.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RGHB.DBCommons" Version="1.6.0" />
                    
Directory.Packages.props
<PackageReference Include="RGHB.DBCommons" />
                    
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 RGHB.DBCommons --version 1.6.0
                    
#r "nuget: RGHB.DBCommons, 1.6.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 RGHB.DBCommons@1.6.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=RGHB.DBCommons&version=1.6.0
                    
Install as a Cake Addin
#tool nuget:?package=RGHB.DBCommons&version=1.6.0
                    
Install as a Cake Tool

RGHB.Commons

Overview

RGHB.Commons is a .NET 9.0 library designed to provide reusable utilities and services for building data-driven applications using Entity Framework Core. It includes a generic repository pattern implementation, extension methods for query pagination, and database initialization interfaces.

Features

  • Generic Repository Pattern: GenericService<TEntity> provides a robust, type-safe implementation for CRUD operations and querying with Entity Framework Core.
  • Pagination Support: EFGeneralService offers a Page extension method for easy query pagination.
  • Unit of Work Pattern: IUnitOfWork interface defines methods for managing database transactions and entity state.
  • Database Initialization: IDbInitializerService interface for initializing and seeding the database.
  • Flexible Querying: Supports filtering, ordering, eager loading, and projections for efficient data retrieval.

Installation

  1. Clone the repository or include the project as a dependency in your .NET solution.
  2. Ensure the following NuGet packages are installed:
    • Microsoft.EntityFrameworkCore (v9.0.2)
    • Microsoft.AspNetCore.Mvc.ViewFeatures (v2.3.0)
  3. Build the project using .NET 9.0 SDK.

Usage

GenericService

The GenericService<TEntity> class provides methods for common database operations. Example:

var service = new GenericService<MyEntity>(unitOfWork);
var entities = await service.GetPagingAsync(
    pageNumZeroStart: 0,
    pageSize: 10,
    orderBy: q => q.OrderBy(e => e.Id),
    includeProperties: "RelatedEntity"
);

Pagination

Use the Page extension method for paginated queries:

var query = dbContext.MyEntities.AsQueryable();
var pagedResult = query.Page(pageNumZeroStart: 1, pageSize: 20);

Database Initialization

Implement IDbInitializerService to initialize and seed your database:

public class MyDbInitializer : IDbInitializerService
{
    public void Initialize() { /* Apply migrations */ }
    public void SeedData() { /* Add default data */ }
}

Project Structure

  • GeneralServices.cs: Contains the EFGeneralService class with pagination utilities.
  • GenericService.cs: Implements the generic repository pattern for Entity Framework Core.
  • IDbInitializerService.cs: Interface for database initialization and seeding.
  • IGenericService.cs: Interface for the generic repository pattern.
  • IUnitOfWork.cs: Interface for the unit of work pattern.

Dependencies

  • .NET 9.0
  • Microsoft.EntityFrameworkCore (v9.0.2)
  • Microsoft.AspNetCore.Mvc.ViewFeatures (v2.3.0)

License

This project is licensed under the MIT License.

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

Showing the top 1 NuGet packages that depend on RGHB.DBCommons:

Package Downloads
RGHB.License

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.8.0 85 11/26/2026
1.6.1 292 11/15/2025
1.6.0 237 11/15/2025
1.5.0 232 9/7/2025
1.4.0 217 9/7/2025
1.3.1 296 8/30/2025
1.3.0 283 8/30/2025
1.2.0 316 8/26/2025
1.1.2 320 8/26/2025
1.1.1 300 8/26/2025
1.1.0 166 8/23/2025
1.0.0 257 6/26/2025