📦 KhatiExtendedAdo – Clean ADO.NET Made Simple
🔧 What It Does
KhatiExtendedAdo is a lightweight .NET library that simplifies and standardizes core ADO.NET operations like Insert, Update, Delete, Bulk Insert, and Get. It abstracts away repetitive boilerplate code while allowing direct control over SQL execution—making ADO.NET more developer-friendly without sacrificing performance.
✅ The Benefits
-
Clean & Maintainable Code: Reduces clutter by encapsulating common database logic.
-
High Performance: Keeps the speed and efficiency of raw ADO.NET.
-
Rapid Development: Helps developers quickly implement CRUD operations without manually writing every SQL statement.
-
Bulk Operation Support: Includes optimized methods for bulk data insertion.
-
Lightweight: Unlike heavy ORMs, it doesn't introduce overhead—ideal for lean applications.
💡 Why Should It Be Used?
Use KhatiExtendedAdo if:
-
You're working with raw ADO.NET and want a cleaner, reusable approach.
-
You prefer control over your SQL logic but dislike repetitive coding.
-
Your project doesn't require a full ORM (like Entity Framework) but still needs structured database operations.
-
You want to improve code readability and reduce code smell in data access layers.
Create Your Database First.
Add Connection String
"ConnectionStrings": {"DevConnection": "Server=BS-483;Database=KhatiExtendedEFImple;Trusted_Connection=True;MultipleActiveResultSets=True;"},
Create Context
public class PersonContext : AdoProperties , IPersonContext{private readonly IConfiguration _configuration;public PersonContext(IConfiguration configuration){_configuration = configuration;}public override string ConnectionString(){return _configuration.GetConnectionString("DevConnection");}public override int TimeOut(){return 300;}}
public interface IPersonContext : IAdoProperties{}
Add Entity
public class Student{[JsonProperty("id")]public int Id { get; set; }[JsonProperty("Name")]public string? Name { get; set; }}
Add Middleware
builder.Services.AdoDependency();builder.Services.AddSingleton<IPersonContext, PersonContext>();
Inside Controller
public class HomeController : Controller{private readonly ILogger<HomeController> _logger;private readonly IPersonContext _personContext;public HomeController(ILogger<HomeController> logger, IPersonContext personContext){_logger = logger;_personContext = personContext;}public async Task<IActionResult> Index(){var insert = await _personContext.SqlWriteAsync("Insert into Student(Name) values (@Name)",new Dictionary<string, object>() { { "@Name", "Washiq Anwar Shamsi" }, });List<Student> students = new List<Student>(){new Student() { Name = "The Rock"},new Student() { Name = "Brock Lesner"}};await _personContext.SqlBulkUploadAsync(students,"Student");var readAll = await _personContext.SqlReadAsync<List<Student>>("select * from Student");var readFilter = await _personContext.SqlReadAsync<List<Student>>("select * from Student where Name = @Name",new Dictionary<string, object>() { { "@Name", "Brock Lesner" }, });var firstOrDefault = await _personContext.SqlReadScalerModelAsync<Student>("select Top 1 * from Student");var readScalerValue = await _personContext.SqlReadScalerValueAsync<int>("select count(*) from Student");return Ok(new{readAll=readAll.Data,readFilter = readFilter.Data,firstOrDefault=firstOrDefault.Data,readScalerValue=readScalerValue.Data});}}