Dapper.Scripts
2.4.1
dotnet add package Dapper.Scripts --version 2.4.1
NuGet\Install-Package Dapper.Scripts -Version 2.4.1
<PackageReference Include="Dapper.Scripts" Version="2.4.1" />
paket add Dapper.Scripts --version 2.4.1
#r "nuget: Dapper.Scripts, 2.4.1"
// 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 | Versions 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. |
-
.NETCoreApp 3.1
- Dapper (>= 2.1.28)
- System.Data.SqlClient (>= 4.8.6)
-
net5.0
- Dapper (>= 2.1.28)
- System.Data.SqlClient (>= 4.8.6)
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 | 5,726 | 3/2/2024 |
2.3.2 | 49,022 | 6/14/2020 |
2.3.1 | 1,997 | 9/23/2018 |
2.3.0 | 1,340 | 7/15/2018 |
2.2.2 | 1,270 | 7/12/2018 |
2.2.1 | 1,306 | 3/20/2018 |
2.2.0 | 1,333 | 3/13/2018 |
2.1.0 | 1,241 | 11/26/2017 |
2.0.3 | 1,273 | 9/11/2017 |
2.0.2 | 1,256 | 9/11/2017 |
2.0.1 | 1,222 | 9/11/2017 |
2.0.0 | 1,247 | 9/11/2017 |
1.50.2.31551 | 1,266 | 9/7/2017 |
1.50.2.25254 | 1,244 | 9/11/2017 |
1.50.2.8255 | 1,252 | 9/11/2017 |
1.50.2.7348 | 1,240 | 9/11/2017 |
1.50.2.7306 | 1,268 | 9/11/2017 |
1.50.2.6947 | 1,278 | 9/7/2017 |
1.50.2.6001 | 1,244 | 9/7/2017 |
1.50.2.5168 | 1,248 | 9/7/2017 |
1.50.2.4627 | 1,258 | 9/7/2017 |
1.50.2.4093 | 1,256 | 9/7/2017 |
1.50.2 | 1,289 | 9/7/2017 |