NPv.DataAccess.Abstractions 1.1.1

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

NPv.DataAccess.Abstractions

Minimal interface contract for generic repository access in .NET applications.


✨ Overview

This library defines core abstractions for working with persistent data in a clean, provider-agnostic way. It includes:

  • IGenericRepository — for standard CRUD operations on aggregate roots or entities
  • ISqlExecutor — for executing raw SQL queries and commands asynchronously

These abstractions are designed to support layered architectures, promote separation of concerns, and enable swapping implementations (e.g., EF Core, Dapper) with minimal friction.


🧱 Interfaces

IGenericRepository

Standard CRUD contract for entity-oriented persistence:

Task<TEntity?> GetAsync<TEntity>(Guid id, string includeProperties = "");
Task<TEntity?> GetAsync<TEntity>(Expression<Func<TEntity, bool>>? filter, string includeProperties = "");
Task<IEnumerable<TEntity>> ListAsync<TEntity>(...);
Task<int> CountAsync<TEntity>(...);
Task AddAsync<TEntity>(TEntity entity);
Task DeleteAsync<TEntity>(Guid id);
...

ISqlExecutor

Lightweight abstraction over raw SQL execution, ideal for high-performance scenarios using Dapper or similar tools:

    Task<T> QueryFirstAsync<T>(string sql, object? parameters = null);
    Task<T?> QueryFirstOrDefaultAsync<T>(string sql, object? parameters = null);
    Task<T> QuerySingleAsync<T>(string sql, object? parameters = null);
    Task<T?> QuerySingleOrDefaultAsync<T>(string sql, object? parameters = null);
    Task<IEnumerable<T>> QueryAsync<T>(string sql, object? parameters = null);
    Task<int> ExecuteAsync(string sql, object? parameters = null);
...

🔧 Usage

Implement the interface in your data layer (e.g., using EF Core):

For IGenericRepository

public class EfGenericRepository : IGenericRepository { ... }

For ISqlExecutor

Implement using your SQL technology of choice, e.g. via Dapper:

public class DapperSqlExecutor : ISqlExecutor { ... }

Inject ISqlExecutor where you need to run raw SQL without managing connections or boilerplate manually.


📦 Installation

This package is published as part of the NPv.Foundation.Net architecture.

To install via NuGet:

dotnet add package NPv.DataAccess.Abstractions

🧩 Related Packages

  • NPv.DataAccess.Ef – EF Core implementation of IGenericRepository
  • NPv.DataAccess.Dapper.Executor – Dapper-based implementation of ISqlExecutor
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 (2)

Showing the top 2 NuGet packages that depend on NPv.DataAccess.Abstractions:

Package Downloads
NPv.DataAccess.Ef

NPv's IGenericRepository realisation for EF including: IDbContextFactory, IDbContextProvider, PerRequestDbContextProvider, ConsoleDbContextProvider

NPv.DataAccess.Dapper.Executor

Dapper-based implementation of ISqlExecutor for raw SQL access in .NET applications. Wraps common Dapper methods and manages connection lifecycle.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 159 6/15/2025
1.1.0 155 6/14/2025
1.0.2 144 6/14/2025
1.0.1 176 5/18/2025
1.0.0 155 5/18/2025