PolyAdo 2025.9.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package PolyAdo --version 2025.9.4
                    
NuGet\Install-Package PolyAdo -Version 2025.9.4
                    
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="PolyAdo" Version="2025.9.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PolyAdo" Version="2025.9.4" />
                    
Directory.Packages.props
<PackageReference Include="PolyAdo" />
                    
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 PolyAdo --version 2025.9.4
                    
#r "nuget: PolyAdo, 2025.9.4"
                    
#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 PolyAdo@2025.9.4
                    
#: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=PolyAdo&version=2025.9.4
                    
Install as a Cake Addin
#tool nuget:?package=PolyAdo&version=2025.9.4
                    
Install as a Cake Tool
  • 📦 Intro & features
  • 🛠️ Installation
  • 💻 Usage (basic CRUD examples)
  • 🌐 Multi-database providers (SQL Server, MySQL, PostgreSQL, Oracle)
  • 🔌 Dependency Injection (with two SQL Server instances demo)
  • 📜 License

PolyAdo

PolyAdo is a lightweight, provider-agnostic ADO.NET abstraction layer for .NET.
It wraps SQL Server, MySQL, PostgreSQL, and Oracle databases into a unified async API.

With PolyAdo, you can:

  • Perform async CRUD operations (ExecuteScalar, ExecuteNonQuery, ExecuteReader, ExecuteQuery).
  • Work with multiple database providers seamlessly.
  • Inject multiple instances of the same database type (e.g., two SQL Server connections) using Dependency Injection.
  • Keep things lightweight — no ORM overhead.

✨ Features

  • ✅ Unified interface for multiple databases
  • ✅ Async operations
  • ✅ Dependency Injection (multi-instance support)
  • ✅ Clean error handling (Success, ErrorMessage, Data)
  • ✅ Extensible design for future providers (e.g., SQLite, MongoDB)

📦 Installation

Install from NuGet:

dotnet add package PolyAdo

Or via Package Manager:

Install-Package PolyAdo

🚀 Usage

Example Table

For demo purposes, assume the following SQL Server table:

CREATE TABLE PolyAdoTestResult (
    [Id] INT IDENTITY PRIMARY KEY NOT NULL,
    [TestName] VARCHAR(100) NOT NULL,
    [Comment] VARCHAR(255),
    [Timestamp] DATETIME2(0)
);

1. Basic CRUD Operations

using PolyAdo.Core;
using System.Collections.Generic;

// Define a settings class
public class SqlServerSetting : IAdoSetting
{
    public string ConnectionString { get; set; }
}

// Create instance
var client = new SqlServer<SqlServerSetting>(new SqlServerSetting
{
    ConnectionString = "Server=.;Database=TestDb;User Id=sa;Password=YourPassword;"
});

// INSERT
var insertResult = await client.ExecuteNonQueryAsync(
    "INSERT INTO PolyAdoTestResult (TestName, Comment, Timestamp) VALUES ('InsertTest', 'Inserted successfully', GETDATE())",
    new Dictionary<string, object>()
);

// READ
var readResult = await client.ExecuteQueryAsync("SELECT * FROM PolyAdoTestResult");
if ((bool)readResult["Success"])
{
    var table = (System.Data.DataTable)readResult["Data"];
    Console.WriteLine($"Fetched {table.Rows.Count} rows.");
}

// UPDATE
var updateResult = await client.ExecuteNonQueryAsync(
    "UPDATE PolyAdoTestResult SET Comment='Updated via PolyAdo' WHERE TestName='InsertTest'",
    new Dictionary<string, object>()
);

// DELETE
var deleteResult = await client.ExecuteNonQueryAsync(
    "DELETE FROM PolyAdoTestResult WHERE TestName='InsertTest'",
    new Dictionary<string, object>()
);

2. Stored Procedure Example

CREATE PROCEDURE usp_PerformTest
    @name VARCHAR(100),
    @comment VARCHAR(255)
AS
BEGIN
    INSERT INTO PolyAdoTestResult (TestName, Comment, Timestamp)
    VALUES (@name, @comment, GETDATE());
END
var spResult = await client.ExecuteNonQueryAsync(
    "usp_PerformTest",
    new Dictionary<string, object>
    {
        { "@name", "SPTest" },
        { "@comment", "Inserted via stored procedure" }
    }
);

3. Dependency Injection (Multiple Instances)

PolyAdo supports multiple DB connections of the same type. For example, you might need two SQL Server databases in the same project.

using Microsoft.Extensions.DependencyInjection;
using PolyAdo.Core;

public class SqlServerSettingA : IAdoSetting
{
    public string ConnectionString { get; set; }
}

public class SqlServerSettingB : IAdoSetting
{
    public string ConnectionString { get; set; }
}

var services = new ServiceCollection();

// Register two SQL Server instances
services.AddSingleton<IAdoClient<SqlServerSettingA>>(sp =>
    new SqlServer<SqlServerSettingA>(new SqlServerSettingA
    {
        ConnectionString = "Server=.;Database=DbA;User Id=sa;Password=YourPassword;"
    })
);

services.AddSingleton<IAdoClient<SqlServerSettingB>>(sp =>
    new SqlServer<SqlServerSettingB>(new SqlServerSettingB
    {
        ConnectionString = "Server=.;Database=DbB;User Id=sa;Password=YourPassword;"
    })
);

var provider = services.BuildServiceProvider();

// Resolve two instances
var dbA = provider.GetRequiredService<IAdoClient<SqlServerSettingA>>();
var dbB = provider.GetRequiredService<IAdoClient<SqlServerSettingB>>();

// Use independently
await dbA.ExecuteNonQueryAsync("INSERT INTO TableA (Col) VALUES ('From DB A')", new());
await dbB.ExecuteNonQueryAsync("INSERT INTO TableB (Col) VALUES ('From DB B')", new());

⚡ Supported Providers

  • ✅ SQL Server (Microsoft.Data.SqlClient)
  • ✅ MySQL (MySql.Data.MySqlClient)
  • ✅ PostgreSQL (Npgsql)
  • ✅ Oracle (Oracle.ManagedDataAccess)

📜 License

MIT License — feel free to use in commercial or open-source projects.


🌟 Roadmap

  • Bulk operations support
  • Extended DI configuration helpers

📢 Feedback & Issues

We’d love to hear your thoughts! If you encounter any issues, have feature requests, or simply want to share feedback, please fill out our short form: https://forms.gle/ogPRAoCrAHRwWzqx5

👉 Submit Feedback & Issues

Your input helps us improve PolyAdo for everyone 🚀


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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.9.5 126 9/8/2025
2025.9.4 141 9/7/2025
2025.9.3 134 9/7/2025
2025.9.2 138 9/7/2025
1.0.0 110 9/6/2025