Install
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard |
README
MuchAdo
A fluent, powerful, efficient library for querying ADO.NET databases.
Quick Start
The MuchAdo class library provides an intuitive API for working with ADO.NET providers like those for MySQL, PostgreSQL, Microsoft SQL Server, and SQLite. It is similar to Dapper and other micro ORMs for .NET.
To use this library, add a reference to the MuchAdo NuGet package that corresponds to your ADO.NET provider. Then create a connection to your database and use it to construct a MuchAdo connector.
| ADO.NET Provider | MuchAdo Package | MuchAdo Connector |
|---|---|---|
| MySqlConnector | MySqlDbConnector | |
| Npgsql | NpgsqlDbConnector | |
| Microsoft.Data.Sqlite | SqliteDbConnector | |
| Microsoft.Data.SqlClient | DbConnector | |
| any ADO.NET provider | DbConnector |
Here's a simple code sample that opens an in-memory SQLite database, creates a table, inserts a few rows within a transaction, and runs a couple of queries. The example uses synchronous methods, which are appropriate for SQLite, but every synchronous method has an equivalent asynchronous method, e.g. ExecuteAsync. There's no risk of SQL injection attacks with the interpolated strings, which use formatted SQL. Try it!
using var connector = new SqliteDbConnector(
new SqliteConnection("Data Source=:memory:"));
connector
.Command("""
create table widgets (
id integer primary key autoincrement,
name text not null,
height real not null)
""")
.Execute();
var widgets = new[]
{
new Widget("First", 6.875),
new Widget("Second", 1.414),
new Widget("Third", 3.1415),
};
using (connector.BeginTransaction())
{
foreach (var widget in widgets)
{
connector
.CommandFormat($"""
insert into widgets (name, height)
values ({widget.Name}, {widget.Height})
""")
.Execute();
}
connector.CommitTransaction();
}
var maxHeight = 5.0;
foreach (var widget in connector
.CommandFormat($"""
select name, height
from widgets
where height <= {maxHeight}
""")
.Query<Widget>())
{
Console.WriteLine($"short: {widget}");
}
var (min, max) = connector
.Command("select min(height), max(height) from widgets")
.QuerySingle<(double, double)>();
Console.WriteLine($"min height {min}, max height {max}");
Changes from Previous Version
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.