NTDLS.SqlManagedConnectivity
1.3.0
See the version list below for details.
dotnet add package NTDLS.SqlManagedConnectivity --version 1.3.0
NuGet\Install-Package NTDLS.SqlManagedConnectivity -Version 1.3.0
<PackageReference Include="NTDLS.SqlManagedConnectivity" Version="1.3.0" />
paket add NTDLS.SqlManagedConnectivity --version 1.3.0
#r "nuget: NTDLS.SqlManagedConnectivity, 1.3.0"
// Install NTDLS.SqlManagedConnectivity as a Cake Addin #addin nuget:?package=NTDLS.SqlManagedConnectivity&version=1.3.0 // Install NTDLS.SqlManagedConnectivity as a Cake Tool #tool nuget:?package=NTDLS.SqlManagedConnectivity&version=1.3.0
NTDLS.SqlManagedConnectivity
📦 Be sure to check out the NuGet package: https://www.nuget.org/packages/NTDLS.SqlManagedConnectivity
Wraps a native SQL Server connection, allows for easy field/value enumeration and manages cleanup.
This library is a replacement for native-style SQL Server access, if you are looking something more POCO/Dapper, then check out the https://github.com/NTDLS/NTDLS.SqlServerDapperWrapper.
Simple example:
In this example we are opening a connection to the local SQL Server (".") and the database ("Dummyload"), then selecting all rows and columns from the table [Test]. This demonstrates how we can enumerate the fields and their types as well as the rows and their values with several options for conversion.
using (var connection = new SqlManagedConnection(".", "Dummyload"))
{
using (var reader = connection.ExecuteQuery("SELECT * FROM Test WHERE Account <> @Account", new { Account = 4104 }))
{
//Loop through all fields:
foreach (var field in reader.Fields)
{
Console.WriteLine($"Field: '{field.Name}', Data Type: '{field.DataTypeName}', Type: '{field.Type.Name}'");
}
//Loop though all rows:
foreach (var row in reader)
{
//Loop though all values in the row:
foreach (var value in row)
{
Console.WriteLine($"{value.Field.Name} -> '{value.As<string>()?.Trim()}'");
}
var doublePercentTaxable1 = row.Value<double>("PercentTaxable");
var decimalPercentTaxable1 = row.Value<decimal>("OriginalAmount");
var stringPercentTaxable1 = row.Value<string>("OriginalAmount");
var intPercentTaxable1 = row.Value<int>("OriginalAmount");
}
}
}
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
-
net6.0
- Microsoft.Data.SqlClient (>= 5.2.1)
-
net7.0
- Microsoft.Data.SqlClient (>= 5.2.1)
-
net8.0
- Microsoft.Data.SqlClient (>= 5.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added simpler converters to row and value objects.