BB84.EntityFrameworkCore.Repositories 4.4.724

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

net80 net100 NuGet

BB84.EntityFrameworkCore.Repositories

This package provides the default repository implementations and DatabaseFacadeExtensions for calling stored procedures and SQL functions.

Installation

dotnet add package BB84.EntityFrameworkCore.Repositories

Repository implementations

GenericRepository<TEntity>

Abstract base for all repositories. Accepts IDbContext as a constructor parameter. All query methods delegate to PrepareQuery(...), which composes Where, IgnoreQueryFilters, Include, OrderBy, Skip, Take, and AsNoTracking into a single IQueryable<TEntity>. Projection overloads use the protected ApplyProjection(query, selector, fieldSelector) helper.

IdentityRepository<TEntity, TKey> / IdentityRepository<TEntity>

Extends GenericRepository<TEntity> with key-based GetById, GetByIds, and bulk Delete/Update by ID. The non-generic overload defaults TKey to Guid.

EnumeratorRepository<TEntity, TKey> / EnumeratorRepository<TEntity>

Extends IdentityRepository with GetByName and GetByNames. The non-generic overload defaults TKey to int.

Usage

Inherit from the appropriate base class and inject IDbContext:

public class ProductRepository : IdentityRepository<Product>, IProductRepository
{
    public ProductRepository(IDbContext dbContext) : base(dbContext) { }

    public async Task<IReadOnlyList<Product>> GetByCategoryAsync(
        int categoryId, CancellationToken token = default)
        => await GetManyByConditionAsync(
            p => p.CategoryId == categoryId,
            orderBy: q => q.OrderBy(p => p.Name),
            token: token);
}

public class CategoryRepository : EnumeratorRepository<ProductCategory>, ICategoryRepository
{
    public CategoryRepository(IDbContext dbContext) : base(dbContext) { }
    // GetByName / GetByNames inherited
}

DI registration:

services.AddScoped<IProductRepository, ProductRepository>();
services.AddScoped<ICategoryRepository, CategoryRepository>();

Calling save changes is the responsibility of the caller (unit-of-work pattern):

repository.Create(entity);
await dbContext.SaveChangesAsync(token);

DatabaseFacadeExtensions

Extension methods on DatabaseFacade (context.Database) for calling SQL Server stored procedures and functions safely with parameterized SQL.

Stored procedures

// Returns rows as IReadOnlyList<T>
IReadOnlyList<ReportRow> rows = context.Database.ExecuteProcedure<ReportRow>(
    schema: "dbo",
    name: "usp_GetReport",
    parameters: [new SqlParameter("@FromDate", fromDate)]);

// Non-generic overload returns rows-affected count
int affected = context.Database.ExecuteProcedure(
    schema: "dbo",
    name: "usp_ArchiveOrders",
    parameters: [new SqlParameter("@CutoffDate", cutoff)]);

// Async variants
await context.Database.ExecuteProcedureAsync<ReportRow>(..., cancellationToken);
await context.Database.ExecuteProcedureAsync(..., cancellationToken);

Output parameters are supported — parameters with Direction = ParameterDirection.Output are emitted as @param = @param OUTPUT in the generated SQL.

Table-valued functions

IReadOnlyList<ProductDto> results = context.Database.ExecuteTableFunction<ProductDto>(
    schema: "dbo",
    name: "fn_GetActiveProducts",
    parameters: [new SqlParameter("@CategoryId", categoryId)]);

await context.Database.ExecuteTableFunctionAsync<ProductDto>(..., cancellationToken);

Scalar-valued functions

decimal? total = context.Database.ExecuteScalarFunction<decimal>(
    schema: "dbo",
    name: "fn_GetOrderTotal",
    parameters: [new SqlParameter("@OrderId", orderId)]);

await context.Database.ExecuteScalarFunctionAsync<decimal>(..., cancellationToken);

All methods sanitize schema/name inputs and use parameterized SQL to prevent injection.

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 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 BB84.EntityFrameworkCore.Repositories:

Package Downloads
BB84.EntityFrameworkCore.Repositories.SqlServer

This package contains the SqlServer specific tuning of the entity type configurations, column type extensions and DatabaseFacade extensions for the use of EntityFrameworkCore with SqlServer.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.1020 88 10/20/2026
5.0.916 390 9/16/2026
5.0.818 302 8/18/2026
4.5.725 223 7/25/2026
4.4.724 140 7/24/2026
4.4.625 229 6/25/2026
4.3.520 316 5/20/2026
4.3.513 198 5/13/2026
4.3.507 154 5/7/2026
4.3.419 249 4/19/2026
4.3.327 288 3/27/2026
4.2.322 179 3/22/2026
4.1.319 161 3/19/2026
4.1.222 246 2/22/2026
4.1.122 219 1/22/2026
4.0.1026 407 10/26/2025
4.0.916 471 9/16/2025
4.0.817 315 8/17/2025
3.1.617 393 6/17/2025
3.1.518 279 5/18/2025
Loading failed