AJDBLib 1.0.2
dotnet add package AJDBLib --version 1.0.2
NuGet\Install-Package AJDBLib -Version 1.0.2
<PackageReference Include="AJDBLib" Version="1.0.2" />
<PackageVersion Include="AJDBLib" Version="1.0.2" />
<PackageReference Include="AJDBLib" />
paket add AJDBLib --version 1.0.2
#r "nuget: AJDBLib, 1.0.2"
#:package AJDBLib@1.0.2
#addin nuget:?package=AJDBLib&version=1.0.2
#tool nuget:?package=AJDBLib&version=1.0.2
AJDBLib
Lightweight and Flexible Database Access Library for .NET AJDBLib is a lightweight and high-performance database access library designed for simplified database operations in .NET applications. It provides an intuitive API for executing queries, inserting, updating, and managing database connections with minimal boilerplate code.
📦 Installation
You can install AJDBLib via NuGet Package Manager:
dotnet add package AJDBLib
🚀 Features
✔ Fluent and Intuitive API – Perform database operations with minimal code.
✔ Supports Multiple Database Providers – SQL Server, MySQL, PostgreSQL, SQLite.
✔ Object Mapping – Auto-map database query results to C# objects.
✔ Secure Parameterized Queries – Prevents SQL injection.
✔ Event-Driven Exception Handling – Handle query errors via custom event listeners.
✔ Property Injection Support – Allows flexible dependency injection.
📌 Quick Start Guide
1️⃣ Creating a Database Connection
using System.Data.SqlClient;
using AJDBLib;
string connectionString = "Server=your_server;Database=your_db;User Id=your_user;Password=your_password;";
var connection = new SqlConnection(connectionString);
// Create an instance of AAJDBControl
AAJDBControl db = new AAJDBControl(connection);
2️⃣ Executing Queries
Querying Multiple Records
var users = db.Query<User>("SELECT * FROM Users WHERE Age > @Age", new { Age = 18 });
foreach (var user in users) {
Console.WriteLine($"{user.Id} - {user.Name}");
}
Querying a Single Record
var user = db.QuerySingle<User>("SELECT * FROM Users WHERE Id = @Id", new { Id = 1 });
Console.WriteLine(user.Name);
3️⃣ Insert Data
int rowsAffected = db.Insert("Users", new { Name = "John Doe", Age = 30 });
Console.WriteLine($"Inserted {rowsAffected} row(s).");
4️⃣ Update Data
int rowsAffected = db.Update("Users", new { Id = 1 }, new { Name = "Jane Doe" });
Console.WriteLine($"Updated {rowsAffected} row(s).");
5️⃣ Handling Query Exceptions via Events You can subscribe to the QueryException event to handle database errors gracefully.
db.QueryException += (Exception ex) ⇒ {
Console.WriteLine($"Database Error: {ex.Message}");
};
🔧 Advanced Usage
1️⃣ Using IDbConnection Extensions
AJDBLib also provides extension methods for IDbConnection, allowing direct query execution.
using System.Data;
using AJDBLib;
IDbConnection connection = new SqlConnection(connectionString);
var users = connection.Query<User>("SELECT * FROM Users");
2️⃣ Using Dictionary Parameters
var users = db.Query<User>("SELECT * FROM Users WHERE Age > @Age", parameters ⇒ parameters.Add("Age", 25));
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net48 is compatible. net481 was computed. |
-
- Newtonsoft.Json (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
This is the first stable release of AAJDBControl, a lightweight and flexible database access library for .NET, fix some bug in OLEDB update.