Dapper.SimpleSqlBuilder.DependencyInjection
5.0.3
dotnet add package Dapper.SimpleSqlBuilder.DependencyInjection --version 5.0.3
NuGet\Install-Package Dapper.SimpleSqlBuilder.DependencyInjection -Version 5.0.3
<PackageReference Include="Dapper.SimpleSqlBuilder.DependencyInjection" Version="5.0.3" />
<PackageVersion Include="Dapper.SimpleSqlBuilder.DependencyInjection" Version="5.0.3" />
<PackageReference Include="Dapper.SimpleSqlBuilder.DependencyInjection" />
paket add Dapper.SimpleSqlBuilder.DependencyInjection --version 5.0.3
#r "nuget: Dapper.SimpleSqlBuilder.DependencyInjection, 5.0.3"
#:package Dapper.SimpleSqlBuilder.DependencyInjection@5.0.3
#addin nuget:?package=Dapper.SimpleSqlBuilder.DependencyInjection&version=5.0.3
#tool nuget:?package=Dapper.SimpleSqlBuilder.DependencyInjection&version=5.0.3
Dapper Simple SQL Builder
![]()
A simple and performant SQL builder for Dapper, using string interpolation and a fluent API to build safe, static, and dynamic SQL queries.
Getting Started
Install via the .NET Core command line interface
dotnet add package Dapper.SimpleSqlBuilder
Or via the NuGet Package Manager Console
Install-Package Dapper.SimpleSqlBuilder
For information on installing other available packages, refer to the Packages section in the documentation.
Usage
The library provides two builders for building SQL queries, which can be created via the static SimpleBuilder class.
Builder- for building static, dynamic, and complex SQL queries.Fluent Builder- for building SQL queries using a fluent API.
The library also provides an alternative to static classes via Dependency Injection.
Create SQL query with the Builder
using Dapper.SimpleSqlBuilder;
var userTypeId = 4;
var role = "Admin";
var builder = SimpleBuilder.Create($@"
SELECT * FROM User
WHERE UserTypeId = {userTypeId} AND Role = {role}");
The concern you might have here is the issue of SQL injection, however this is mitigated by the library as the SQL statement is converted to this.
SELECT * FROM User
WHERE UserTypeId = @p0 AND Role = @p1
And all values passed into the interpolated string are taken out and replaced with parameter placeholders. The parameter values are put into Dapper's DynamicParameters collection.
To execute the query with Dapper is as simple as this:
var users = dbConnection.Query<User>(builder.Sql, builder.Parameters);
To learn more about the Builder, refer to the Builder section in the documentation.
Create SQL query with the Fluent Builder
using Dapper.SimpleSqlBuilder;
var userTypeId = 4;
var roles = new[] { "Admin", "User" };
var builder = SimpleBuilder.CreateFluent()
.Select($"*")
.From($"User")
.Where($"UserTypeId = {userTypeId}")
.Where($"Role IN {roles}");
// Execute the query with Dapper
var users = dbConnection.Query<User>(builder.Sql, builder.Parameters);
The generated SQL will be:
SELECT *
FROM User
WHERE UserTypeId = @p0 AND Role IN @pc1_
When the query is executed, Dapper will expand the parameter pc1_ into individual parameters (pc1_1, pc1_2, etc.) for each value in the collection.
To learn more about the Fluent Builder, refer to the Fluent Builder section in the documentation.
The Docs 📚
For advanced configuration options including parameter naming conventions, prefixes, and other settings, visit the Builder Settings section in the documentation.
Explore the complete Documentation to learn more about the library's features and usage.
Share Your Feedback
If you like the library, use it, share it, and give it a ⭐️. For any suggestions, feature requests, or issues feel free to create an issue to help improve the library.
Contributing
Refer to the Contributing guide for more details.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgements
Refer to the Acknowledgements page for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. 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 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 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Dapper (>= 2.1.79)
- Dapper.SimpleSqlBuilder (>= 5.0.3)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.11)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.11)
-
net10.0
- Dapper (>= 2.1.79)
- Dapper.SimpleSqlBuilder (>= 5.0.3)
- Microsoft.Extensions.Configuration (>= 10.0.11)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.11)
-
net8.0
- Dapper (>= 2.1.79)
- Dapper.SimpleSqlBuilder (>= 5.0.3)
- Microsoft.Extensions.Configuration (>= 10.0.11)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.11)
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 |
|---|---|---|
| 5.0.3 | 37 | 9/6/2026 |
| 5.0.1-beta | 33 | 9/6/2026 |
| 4.2.3 | 14,668 | 1/4/2025 |
| 4.2.1-beta | 204 | 1/4/2025 |
| 4.2.0-beta | 237 | 1/3/2025 |
| 4.1.2 | 270 | 12/1/2024 |
| 4.1.1-beta | 205 | 12/1/2024 |
| 4.1.0-beta | 189 | 11/30/2024 |
| 4.0.5 | 2,416 | 7/4/2024 |
| 4.0.3-beta | 244 | 7/3/2024 |
| 4.0.0-beta | 233 | 7/1/2024 |
| 3.7.4 | 384 | 5/19/2024 |
| 3.7.2-beta | 202 | 5/15/2024 |
| 3.7.0-beta | 176 | 5/15/2024 |
| 3.6.2 | 325 | 2/6/2024 |
| 3.6.0-beta | 221 | 2/6/2024 |
| 3.5.1 | 387 | 12/13/2023 |
| 3.5.0-beta | 214 | 12/13/2023 |
| 3.4.1 | 302 | 10/30/2023 |
| 3.4.0-beta | 244 | 10/29/2023 |