DatabaseLibraryMDS 3.0.14
dotnet add package DatabaseLibraryMDS --version 3.0.14
NuGet\Install-Package DatabaseLibraryMDS -Version 3.0.14
<PackageReference Include="DatabaseLibraryMDS" Version="3.0.14" />
<PackageVersion Include="DatabaseLibraryMDS" Version="3.0.14" />
<PackageReference Include="DatabaseLibraryMDS" />
paket add DatabaseLibraryMDS --version 3.0.14
#r "nuget: DatabaseLibraryMDS, 3.0.14"
#:package DatabaseLibraryMDS@3.0.14
#addin nuget:?package=DatabaseLibraryMDS&version=3.0.14
#tool nuget:?package=DatabaseLibraryMDS&version=3.0.14
About
The DatabaseLibraryMDS is a library for accessing Sql Server databases using the Microsoft.Data.SqlClient. Built with .NET 8, .NET 9, and .NET 10, the DatabaseLibraryMDS is a dll for performing CRUD operations on a SQL Server database with minimal code for the developer.
Key Features
- Makes reading and writing data to and from a database easier with less coding
- Automatically maps columns to properties when retrieving data
- Converts returning values according to the data type of the property
- Supports setting the query timeout
- Supports Async calls
- Supports Transactions
- Supports logging errors to the Windows Event Log
- Supports Unit Testing
- SourceLink enabled for step-through debugging from NuGet
How to Use
Executes a query that returns a List<Email>
public List<Email> Email(string connectionString, string parameter)
{
try
{
using (var ss = new SqlServer(connectionString, CommandType.StoredProcedure))
{
string queryString = "Runbook.dbo.cspGetEmailByEmailId";
ss.AddParameter("@parameter", parameter);
return ss.ExecuteReader<Email>(queryString);
}
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
}
Executes an Insert statement that returns a Guid for the record ID
NOTE: The stored procedure will need to OUTPUT the new ID
public Guid Email(string connectionString, Email Email)
{
try
{
using (var ss = new SqlServer(connectionString, CommandType.StoredProcedure))
{
string spName = "Runbook.dbo.cspAddEmail";
return ss.ExecuteForGuid(spName, Email);
}
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
}
BulkInserts
// Example — synchronous DataTable bulk insert (with transaction)
using System;
using System.Data;
using DatabaseLibraryMDS;
var dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("CreatedAt", typeof(DateTime));
dt.Rows.Add(1, "Alice", DateTime.UtcNow);
dt.Rows.Add(2, "Bob", DateTime.UtcNow);
string connectionString = "Server=.;Database=MyDb;Trusted_Connection=True;";
using var sql = new SqlServer(connectionString, System.Data.CommandType.Text, Timeout: 60, useEventLogs: false);
try
{
sql.BeginTrans(); // optional — BulkInsert will enlist in DbCommand.Transaction when present
int attempted = sql.BulkInsert(dt, "dbo.MyTargetTable", batchSize: 500);
sql.CommitTrans();
Console.WriteLine($"Rows attempted: {attempted}");
}
catch (Exception ex)
{
try { sql.RollbackTrans(); } catch { }
Console.WriteLine($"BulkInsert failed: {ex.Message}");
}
// Example — async POCO list bulk insert (requires ToDataTable() extension used in this project)
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DatabaseLibraryMDS;
public record Person(int Id, string Name, DateTime CreatedAt);
async Task ExampleAsync()
{
var items = new List<Person>
{
new Person(1, "Alice", DateTime.UtcNow),
new Person(2, "Bob", DateTime.UtcNow)
};
string connectionString = "Server=.;Database=MyDb;Trusted_Connection=True;";
await using var sql = new SqlServer(connectionString, System.Data.CommandType.Text, Timeout: 60);
try
{
int attempted = await sql.BulkInsertAsync(items, "dbo.MyTargetTable", batchSize: 1000);
Console.WriteLine($"Rows attempted: {attempted}");
}
catch (Exception ex)
{
Console.WriteLine($"BulkInsertAsync failed: {ex.Message}");
throw;
}
}
await ExampleAsync();
Changelog
v3.0.14
- Fixed NuGet packaging: embedded debug symbols for consumer debugging, added SourceLink support
- Per-TFM System.Diagnostics.EventLog versions (8.0.1 / 9.0.3 / 10.0.1)
v3.0.13
- Added ExecuteForInt and ExecuteForIntAsync and updated ExecuteForLongAsync numeric return type handler
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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 is compatible. 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. |
-
net10.0
- Microsoft.Data.SqlClient (>= 6.1.3)
- System.Diagnostics.EventLog (>= 10.0.1)
-
net8.0
- Microsoft.Data.SqlClient (>= 6.1.3)
- System.Diagnostics.EventLog (>= 8.0.1)
-
net9.0
- Microsoft.Data.SqlClient (>= 6.1.3)
- System.Diagnostics.EventLog (>= 9.0.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DatabaseLibraryMDS:
| Package | Downloads |
|---|---|
|
BlazorChat.Server.SqlServer
SQL Server persistence provider for BlazorChat.Server. Production-ready database storage implementation. Auto-installs BlazorChat.Server dependency. Requires SQL Server 2016+ or Azure SQL Database. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.14 | 35 | 3/13/2026 |
| 3.0.13 | 104 | 3/7/2026 |
| 3.0.12 | 360 | 12/19/2025 |
| 3.0.11 | 278 | 11/7/2025 |
| 3.0.10 | 213 | 11/5/2025 |
| 3.0.9 | 1,488 | 7/21/2025 |
| 3.0.8.1 | 143 | 7/18/2025 |
| 3.0.8 | 142 | 7/18/2025 |
| 3.0.7 | 290 | 6/25/2025 |
| 3.0.6 | 588 | 5/18/2025 |
| 3.0.5 | 199 | 5/17/2025 |
| 3.0.4 | 285 | 5/16/2025 |
| 3.0.3 | 291 | 5/15/2025 |
| 3.0.2 | 296 | 5/15/2025 |
| 3.0.1 | 49,983 | 5/15/2025 |
3.0.14 - Fixed NuGet packaging: embedded debug symbols for consumer debugging, added SourceLink support
3.0.13 - Added ExecuteForInt and ExecuteForIntAsync and updated ExecuteForLongAsync numeric return type handler