Kull.Data 6.1.0

.NET 6.0 .NET Standard 2.0 .NET Framework 4.7
NuGet\Install-Package Kull.Data -Version 6.1.0
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.
dotnet add package Kull.Data --version 6.1.0
<PackageReference Include="Kull.Data" Version="6.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kull.Data --version 6.1.0
#r "nuget: Kull.Data, 6.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Kull.Data as a Cake Addin
#addin nuget:?package=Kull.Data&version=6.1.0

// Install Kull.Data as a Cake Tool
#tool nuget:?package=Kull.Data&version=6.1.0

Kull.Data Database Access

This Library extends the .Net Standard DBA Classes like System.Data.Common.DbConnection or System.Data.Common.DbDataReader with some extension methods that makes them easiert to use. You can use this a very simple ORM Mapper as well, without the need of a full-bown Entity Framework. A good alternative is Dapper.

Install it using Nuget, Package "Kull.Data":

NuGet Badge

Some Examples

You always need to be using Kull.Data to use the extension methods.

Call a Stored Procedure

using (var con = Kull.Data.DatabaseUtils.GetConnectionFromConfig("SomeConfigConnstr"))
{
    return con.CreateSPCommand("spGetSomeData")
        .AddCommandParameter("NameOfParameter", 1)
        .AddCommandParameter("NameofOtherPArameter", 2)
        .AsCollectionOf<SomeClassName>() // As of v6, a C# 9 record can be used here
}

Call a Stored Procedure, but use default DataReader

System.Data.Common.DbCommand cmd = con.CreateSPCommand("spGetSomeData")
                    .AddCommandParameter("NameOfParameter", 1)
                    .AddCommandParameter("NameofOtherPArameter", 2);

using(var rdr = cmd.ExecuteReader())
{
    rdr.Read();
    return rdr.GetNInt16(2); // Use Kull.Data Extension method that handles null-values for you (No System.DBNull Checking anymore...)
}

Abstraction of Config

You can simple call Kull.Data.DatabaseUtils.GetConnectionFromConfig("NAMEOFCONNECTIONSTRING") and it will return your DbConnection.

It works in the following order:

  • Look in System.Configuration.ConfigurationManager.ConnectionStrings (.Net Fx only)
  • Look in System.Configuration.ConfigurationManager.AppSettings (.Net Fx only)
  • Look in appsettings.json (.Net Core only)
  • Look in Environment Variables

When looking into Environment Variables, the ones of Azure functions are the base. We support the following prefixes:

  • No prefix, meaning just NAMEOFCONNECTIONSTRING in the example above
  • SQLCONNSTR_
  • SQLAZURECONNSTR_
  • MYSQLCONNSTR_
  • PostgreSQLCONNSTR_
  • CUSTOMCONNSTR_

Other Feature: WrapperDataReader and ObjectDataReader

For SQL Bulk Copy or other things it can be useful to pass C# Data as a DataReader. You can achieve that by using Kull.Data.DataReader.ObjectDataReader. If you need to add some columns to a datareader, you can use Kull.Data.DataReader.WrappedDataReader.

Powershell Module

You can use the Kull.Data.Powershell Module to use some simple cmdlets that allow for querying stored procedures(queries with parameters easily.

Import-Module SqlServer # To load System.Data.SqlClient driver in Powershell 6.2+
Import-Module Kull.Data.Powershell 
$allAssemblies = [appdomain]::currentdomain.GetAssemblies() | ForEach-Object { [IO.Path]::GetFileName($_.Location) } # we try to be ready when SqlServer Module uses Microsoft.Data.SqlClient
if($allAssemblies.Contains("System.Data.SqlClient.dll") -and -not $allAssemblies.Contains("Microsoft.Data.SqlClient.dll")){
    $provider = "System.Data.SqlClient"
} else {
    $provider = "Microsoft.Data.SqlClient"
}
if($firstLoad -and $provider -eq "System.Data.SqlClient"){
    [System.Data.Common.DbProviderFactories]::RegisterFactory($provider, [System.Data.SqlClient.SqlClientFactory]::Instance)
}
else {
    [System.Data.Common.DbProviderFactories]::RegisterFactory($provider, [Microsoft.Data.SqlClient.SqlClientFactory]::Instance)
}
$sqlcon = Connect-Database $connectionstring $provider
Send-DbCommand $sqlcon $commandText $parameters ([System.Data.CommandType]::StoredProcedure)
# Or, use Receive-DbData to get result list
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Kull.Data:

Package Downloads
Kull.GenericBackend

Package Description

Kull.DatabaseMetadata

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.1.0 42 9/22/2022
6.1.0-beta8 88 7/30/2022
6.1.0-beta7 56 7/30/2022
6.1.0-beta6 56 7/15/2022
6.1.0-beta5 59 7/8/2022
6.1.0-beta4 56 7/8/2022
6.1.0-beta3 50 7/7/2022
6.1.0-beta2 50 7/7/2022
6.1.0-beta1 51 7/7/2022
6.0.5 215 6/22/2022
6.0.4 91 6/14/2022
6.0.3 433 3/21/2022
6.0.2 220 3/18/2022
6.0.1 282 1/12/2022
6.0.0 1,310 10/23/2021
6.0.0-beta9 478 9/28/2021
6.0.0-beta8 88 9/23/2021
6.0.0-beta7 192 9/10/2021
6.0.0-beta6 95 8/30/2021
6.0.0-beta5 87 8/30/2021
6.0.0-beta4 82 8/30/2021
6.0.0-beta3 86 8/30/2021
6.0.0-beta2 96 8/27/2021
6.0.0-beta1 97 8/27/2021
5.4.1 1,044 7/29/2021
5.4.0 974 4/13/2021
5.4.0-rc2 186 1/26/2021
5.4.0-rc1 377 9/24/2020
5.3.0 2,221 8/19/2020
5.2.1 1,739 4/30/2020
5.2.0 405 3/23/2020
5.2.0-beta1 317 1/9/2020
5.1.0 2,468 8/14/2019
5.0.3 490 11/22/2019
5.0.2 341 11/22/2019
5.0.1 393 11/22/2019
4.1.1 345 11/22/2019
2.0.4 336 11/22/2019