AJDBLib 1.0.2

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

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 Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 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
1.0.2 2,268 3/13/2025
1.0.1 221 3/12/2025

This is the first stable release of AAJDBControl, a lightweight and flexible database access library for .NET, fix some bug in OLEDB update.