RA.Utilities.Data.Abstractions 10.0.0

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

RA.Utilities.Data.Abstractions

NuGet version Codecov NuGet Downloads Documentation GitHub license

RA.Utilities.Data.Abstractions provides a set of core interfaces for implementing common data access patterns, such as the Repository and Unit of Work. It solves the problem of tightly coupling your business logic to a specific data access technology (like Entity Framework Core).

By coding against these abstractions, you can create a clean, decoupled architecture where the data access layer can be swapped out with minimal impact on your application's core logic.

Getting started

You can install the package via the .NET CLI:

dotnet add package RA.Utilities.Data.Abstractions

Prerequisites

This package contains only interfaces and is designed to be used with a concrete implementation. For example, you would create your own repository classes that implement these interfaces using an ORM like Entity Framework Core.

It is also recommended to use this package with RA.Utilities.Data.Entities, as the repository interfaces are constrained to IEntity.

Usage

The package provides two main interfaces: IRepository<TEntity, TKey> and IUnitOfWork.

IRepository<TEntity, TKey>

This generic interface defines standard CRUD (Create, Read, Update, Delete) operations for an entity.

// An example of a concrete repository implementation
using RA.Utilities.Data.Abstractions;

public class ProductRepository : IRepository<Product, int>
{
    private readonly AppDbContext _context;

    public ProductRepository(AppDbContext context)
    {
        _context = context;
    }

    public async Task<Product> GetByIdAsync(int id, CancellationToken cancellationToken)
    {
        return await _context.Products.FindAsync(id, cancellationToken);
    }

    public void Add(Product entity)
    {
        _context.Products.Add(entity);
    }

    // ... other method implementations
}

IUnitOfWork

This interface represents a transaction that groups multiple repository operations. It ensures that a series of changes are either all committed or all rolled back, maintaining data integrity.

// An example of a Unit of Work implementation with EF Core
public class UnitOfWork : IUnitOfWork
{
    private readonly AppDbContext _context;

    public UnitOfWork(AppDbContext context)
    {
        _context = context;
    }

    public Task<int> SaveChangesAsync(CancellationToken cancellationToken)
    {
        return _context.SaveChangesAsync(cancellationToken);
    }
}

Injecting into a Service

You can then inject these abstractions into your business services, completely decoupling them from EF Core's DbContext.

public class ProductService
{
    private readonly IRepository<Product, int> _productRepository;
    private readonly IUnitOfWork _unitOfWork;

    public ProductService(IRepository<Product, int> productRepository, IUnitOfWork unitOfWork)
    {
        _productRepository = productRepository;
        _unitOfWork = unitOfWork;
    }

    public async Task CreateProductAsync(Product product, CancellationToken cancellationToken)
    {
        _productRepository.Add(product);
        await _unitOfWork.SaveChangesAsync(cancellationToken);
    }
}

Additional documentation

For more information on how this package fits into the larger RA.Utilities ecosystem, please see the officially documentation.

Feedback

If you have suggestions or find a bug, please open an issue in the RA.Utilities GitHub repository. Contributions are welcome!

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 RA.Utilities.Data.Abstractions:

Package Downloads
RA.Utilities.Data.EntityFramework

Provides generic repository base classes for implementing the Repository and Unit of Work patterns with Entity Framework Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.2 83 1/11/2026
10.0.1 223 12/14/2025
10.0.0 207 11/24/2025
10.0.0-rc.2 159 10/30/2025