Dapper.Scripts 2.4.1

dotnet add package Dapper.Scripts --version 2.4.1                
NuGet\Install-Package Dapper.Scripts -Version 2.4.1                
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="Dapper.Scripts" Version="2.4.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dapper.Scripts --version 2.4.1                
#r "nuget: Dapper.Scripts, 2.4.1"                
#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.
// Install Dapper.Scripts as a Cake Addin
#addin nuget:?package=Dapper.Scripts&version=2.4.1

// Install Dapper.Scripts as a Cake Tool
#tool nuget:?package=Dapper.Scripts&version=2.4.1                

Dapper Scripts

Extension of Dapper which supports binding a collection of SQL scripts to a SqlConnection.

Avoid embedding SQL text strings into your code, and leverage syntax hightlighting, by storing your SQL operations in external *.sql files. Dapper scripts binds a collection of key-based sql strings to a connection factory, allowing you to keep your database code clean. All extensions match the original dapper commands, but using a *Script suffix.

Setup

static class Sql
{
    public static SqlScriptConnectionFactory SampleDatabase {get;}
    
    static Sql()
    {
        var scripts = new SqlScriptCollection();
        scripts.Add.FromFile("test-query", "query.sql");

        DatabaseName = new SqlScriptConnectionFactory(scripts);
        DatabaseName.ConnectionString = "Server: ...;";
    }
}

Note: For best results, it is recommended to use Embedded Content as the Content Type for your sql files. This will allow them to be stored within your assembly file after compiling.

Usage

using (var connection = Sql.SampleDatabase.Connect()) {
    return connection.QueryScript("test-query", new {arg = value});
}

For more examples, visit the WiKi.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.4.1 7,674 3/2/2024
2.3.2 54,508 6/14/2020
2.3.1 2,011 9/23/2018
2.3.0 1,349 7/15/2018
2.2.2 1,279 7/12/2018
2.2.1 1,315 3/20/2018
2.2.0 1,344 3/13/2018
2.1.0 1,250 11/26/2017
2.0.3 1,283 9/11/2017
2.0.2 1,265 9/11/2017
2.0.1 1,234 9/11/2017
2.0.0 1,256 9/11/2017
1.50.2.31551 1,276 9/7/2017
1.50.2.25254 1,254 9/11/2017
1.50.2.8255 1,261 9/11/2017
1.50.2.7348 1,253 9/11/2017
1.50.2.7306 1,277 9/11/2017
1.50.2.6947 1,287 9/7/2017
1.50.2.6001 1,254 9/7/2017
1.50.2.5168 1,257 9/7/2017
1.50.2.4627 1,267 9/7/2017
1.50.2.4093 1,282 9/7/2017
1.50.2 1,298 9/7/2017