Infrastructure.Data.Abstractions 10.0.0

dotnet add package Infrastructure.Data.Abstractions --version 10.0.0
                    
NuGet\Install-Package Infrastructure.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="Infrastructure.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="Infrastructure.Data.Abstractions" Version="10.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Infrastructure.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 Infrastructure.Data.Abstractions --version 10.0.0
                    
#r "nuget: Infrastructure.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 Infrastructure.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=Infrastructure.Data.Abstractions&version=10.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Infrastructure.Data.Abstractions&version=10.0.0
                    
Install as a Cake Tool

Infrastructure.Data.Abstractions

CI NuGet

A .NET 10.0 collection of data access interfaces. Provides contracts for repositories, unit of work, blob storage, cache, and mapping — keeping your domain and application layers free from infrastructure dependencies.


Installation

dotnet add package Infrastructure.Data.Abstractions

Interfaces

IRepository<TEntity, TKey>

Full CRUD contract for an entity with a typed key.

public class ProductRepository : IRepository<Product, Guid>
{
    public Task<IEnumerable<Product>> GetAll() { ... }
    public Task<IEnumerable<Product>> GetAll(Expression<Func<Product, bool>> predicate) { ... }
    public Task<Product> GetByID(Guid id) { ... }
    public Task<bool> FindByID(Guid id) { ... }
    public Task<Guid> Add(Product entity) { ... }
    public Task Update(Product item, Guid id) { ... }
    public Task DeleteBy(Product entity) { ... }
    public Task DeleteBy(Guid id) { ... }
}

Register and inject:

// registration
services.AddScoped<IRepository<Product, Guid>, ProductRepository>();

// injection
public class ProductService(IRepository<Product, Guid> repository) { }

IUnitOfWork

Wraps a database transaction. Obtain the open connection inside the transaction scope.

public class OrderService(IUnitOfWork uow, IRepository<Order, int> orders)
{
    public async Task PlaceOrder(Order order)
    {
        uow.Begin();
        try
        {
            await orders.Add(order);
            uow.Commit();
        }
        catch
        {
            uow.Rollback();
            throw;
        }
    }
}

IBlobStorage

Upload and download files from a binary store.

public class ReportService(IBlobStorage storage)
{
    public async Task SaveReport(Report report, string fileName)
    {
        await storage.Upload(report, fileName);
    }

    public async Task<Stream> LoadReport(string fileName)
    {
        return await storage.Download(fileName);
    }
}

IBlobStorageRepository<TEntity>

Typed access to blob-backed entities with a work queue.

public class DocumentService(IBlobStorageRepository<Document> repository)
{
    public async Task<Document> Load(string key)
    {
        return await repository.GetByKey(key);
    }
}

ICacheProvider

Key-based cache abstraction.

public class CachedProductService(
    IRepository<Product, Guid> repository,
    ICacheProvider cache)
{
    public async Task<Product> GetProduct(Guid id)
    {
        var key = $"product:{id}";
        var cached = await cache.Get<Product>(key);
        if (cached is not null) return cached;

        var product = await repository.GetByID(id);
        await cache.Add(product, key);
        return product;
    }
}

ISimpleMapper<TIn, TOut>

One-way mapping between two types.

public class ProductMapper : ISimpleMapper<ProductDto, Product>
{
    public Product Map(ProductDto dto) => new Product
    {
        Id   = dto.Id,
        Name = dto.Name
    };
}

SensitiveDataAttribute

Marks properties that contain sensitive information. Use in logging, serialization filters, or audit pipelines to suppress sensitive fields.

public class Customer
{
    public string Name { get; set; }

    [SensitiveData]
    public string TaxId { get; set; }

    [SensitiveData]
    public string CardNumber { get; set; }
}

Composing granular contracts

All query and command interfaces are available individually so you can expose only what a consumer needs:

// read-only service dependency
public class ReportService(IGetAll<Order> orders) { }

// write-only service dependency
public class ImportService(IAdd<Product, Guid> products) { }

Available granular interfaces:

Interface Method
IGetAll<TEntity> GetAll()
IGetAllByExpression<TEntity> GetAll(predicate)
IGetById<TEntity, TKey> GetByID(TKey)
IFindByID<TKey> FindByID(TKey)
IAdd<TEntity, TKey> Add(TEntity) → TKey
IUpdate<TEntity, TKey> Update(TEntity, TKey)
IDelete<TEntity> DeleteBy(TEntity)
IDeleteById<TKey> DeleteBy(TKey)

Migration from v8.1

The dynamic-based interfaces (IRepository<TEntity>, IQuery<TEntity>, ICommand<TEntity>, IGetById<TEntity>, IFindByID, IAdd<TEntity>, IUpdate<TEntity>, IDeleteById) are still present but marked [Obsolete]. Existing code compiles with a warning. Migrate by adding the key type:

// before
public class OrderRepository : IRepository<Order> { ... }

// after
public class OrderRepository : IRepository<Order, int> { ... }

The obsolete interfaces will be removed in a future major release.


License

MIT — see LICENSE.

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 (3)

Showing the top 3 NuGet packages that depend on Infrastructure.Data.Abstractions:

Package Downloads
Infrastructure.Data.CosmosDb

Generic repository base class for Azure Cosmos DB, implementing the repository pattern from Infrastructure.Data.Abstractions. Supports CosmosClient injection, automatic database and container creation, and overridable protected methods for easy customization and unit testing.

Infrastructure.Data.Dapper

A .NET 8.0 Repository and UnitOfWork implementation over Dapper.Contrib

Infrastructure.Data.BlobStorage

A .NET 8.0 BlobStorage Repository based on Microsoft samples

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0 168 6/12/2026
8.0.0 9,780 1/29/2024
6.0.0 2,771 1/25/2022
2.1.0 1,432 11/5/2021
2.0.0 2,067 10/25/2021
1.0.3 1,152 9/14/2021
1.0.1 3,422 1/19/2021

Migrated to .NET 10. Added typed-key interfaces (IRepository<TEntity, TKey>, IQuery<TEntity, TKey>, ICommand<TEntity, TKey>). Dynamic-based interfaces deprecated.