DatabaseLibraryMDS 3.0.12
dotnet add package DatabaseLibraryMDS --version 3.0.12
NuGet\Install-Package DatabaseLibraryMDS -Version 3.0.12
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="DatabaseLibraryMDS" Version="3.0.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DatabaseLibraryMDS" Version="3.0.12" />
<PackageReference Include="DatabaseLibraryMDS" />
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 DatabaseLibraryMDS --version 3.0.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DatabaseLibraryMDS, 3.0.12"
#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 DatabaseLibraryMDS@3.0.12
#: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=DatabaseLibraryMDS&version=3.0.12
#tool nuget:?package=DatabaseLibraryMDS&version=3.0.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
About
The DatabaseLibraryMDS is a library for accessing Sql Server databases using the Microsoft.Data.SqlClient.
Built with .NET 8 the DatabaseLibraryMDS library is 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
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();
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
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 (>= 10.0.1)
-
net9.0
- Microsoft.Data.SqlClient (>= 6.1.3)
- System.Diagnostics.EventLog (>= 10.0.1)
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 |
|---|---|---|
| 3.0.12 | 354 | 12/19/2025 |
| 3.0.11 | 274 | 11/7/2025 |
| 3.0.10 | 208 | 11/5/2025 |
| 3.0.9 | 1,344 | 7/21/2025 |
| 3.0.8.1 | 138 | 7/18/2025 |
| 3.0.8 | 138 | 7/18/2025 |
| 3.0.7 | 283 | 6/25/2025 |
| 3.0.6 | 585 | 5/18/2025 |
| 3.0.5 | 195 | 5/17/2025 |
| 3.0.4 | 282 | 5/16/2025 |
| 3.0.3 | 285 | 5/15/2025 |
| 3.0.2 | 290 | 5/15/2025 |
| 3.0.1 | 49,975 | 5/15/2025 |
3.0.12 - Updated library for .net9.0 and .net10.0