ImanSoftware.DataAccess 1.0.0

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

ImanSoftware.DataAccess

Version: 1.0.0 | Last Updated: August 2026

A lightweight and extensible data access abstraction for .NET with support for parameterized queries, stored procedures, transactions, and Outcome-based results.

ImanSoftware.DataAccess provides a clean abstraction over SQL data access, allowing applications to execute queries and manage transactions without being tightly coupled to a specific implementation. All operations return Outcome objects, enabling consistent error handling without relying on exceptions for expected failures.


Installation

Install the package using the .NET CLI:

dotnet add package ImanSoftware.DataAccess

Why ImanSoftware.DataAccess?

Writing data access code often leads to repetitive connection management, transaction handling, and exception handling.

This package centralizes those concerns behind a simple abstraction while integrating seamlessly with ImanSoftware.Outcome for explicit success and failure handling.

Benefits include:

  • Clean Architecture friendly
  • Dependency Injection compatible
  • Transaction support
  • Parameterized SQL execution
  • Stored Procedure support
  • Consistent Outcome-based error handling

Features

  • ISqlDataAccessor
  • IDbConnectionFactory
  • ITransactionScope
  • ✅ Async API
  • ✅ Parameterized queries
  • ✅ Stored Procedure support
  • ✅ Ad-hoc SQL support
  • ✅ Transaction management
  • Outcome-based results
  • ✅ Dependency Injection support

ISqlDataAccessor

The primary abstraction for executing SQL commands.

Available methods:

  • QuerySingleAsync<T>()
  • QueryAsync<T>()
  • ExecuteAsync()
  • ExecuteScalarAsync<T>()
  • BeginTransactionAsync()

Example:

var result = await _db.QuerySingleAsync<Product>(
    "GetProductById",
    new { Id = id },
    CommandType.StoredProcedure);

All methods return Outcome objects, allowing failures to be handled explicitly.


IDbConnectionFactory

Responsible for creating database connections.

This abstraction keeps your application independent from any specific database provider and centralizes connection creation.


ITransactionScope

Provides an abstraction for database transactions.

Available methods:

  • CommitAsync()
  • RollbackAsync()

Example:

await using var transaction =
    await _db.BeginTransactionAsync();

await _db.ExecuteAsync(...);

await transaction.CommitAsync();

If an error occurs:

await transaction.RollbackAsync();

Stored Procedures

Execute stored procedures easily.

await _db.QuerySingleAsync<Product>(
    "GetProductById",
    new
    {
        Id = id
    },
    CommandType.StoredProcedure);

Ad-hoc SQL Queries

Parameterized SQL queries are also supported.

await _db.QueryAsync<Product>(
    @"SELECT *
      FROM Products
      WHERE CategoryId = @CategoryId",
    new
    {
        CategoryId = categoryId
    });

Outcome-Based Results

Every database operation returns an Outcome.

Example:

var result = await _db.QuerySingleAsync<Product>(...);

if (result.IsSuccess)
{
    Product product = result.Value;
}
else
{
    Console.WriteLine(result.Error.Message);
}

This provides predictable error handling without relying on exceptions for expected scenarios.


Dependency Injection

Register the data access services:

services.AddDataAccess(connectionString);

After registration, ISqlDataAccessor can be injected anywhere in your application.


Example

using ImanSoftware.DataAccess;

public class ProductService
{
    private readonly ISqlDataAccessor _db;

    public ProductService(ISqlDataAccessor db)
    {
        _db = db;
    }

    public async Task<Outcome<Product>> GetProductAsync(int id)
    {
        return await _db.QuerySingleAsync<Product>(
            "GetProductById",
            new
            {
                Id = id
            },
            CommandType.StoredProcedure);
    }
}

Transaction Example

await using var transaction =
    await _db.BeginTransactionAsync();

await _db.ExecuteAsync(...);

await _db.ExecuteAsync(...);

await transaction.CommitAsync();

Design Goals

  • Clean abstraction
  • Async-first API
  • Dependency Injection friendly
  • Transaction support
  • Provider independent
  • Lightweight
  • High performance
  • Outcome-based error handling
  • Clean Architecture compatible

Requirements

  • .NET Standard 2.0+
  • .NET 6+
  • .NET 7+
  • .NET 8+
  • .NET 9+
  • .NET 10.0+

Dependencies

  • ImanSoftware.Outcome

Author

Iman Estiri

📧 contact.imanestiri@gmail.com

📧 dev.imanestiri@gmail.com

GitHub:

https://github.com/ImanEstiri


License

This project is licensed under the MIT 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 (1)

Showing the top 1 NuGet packages that depend on ImanSoftware.DataAccess:

Package Downloads
ImanSoftware.DataAccess.Dapper

Dapper implementation of ImanSoftware.DataAccess for high-performance SQL operations.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 162 8/3/2026