SQLHelper.DB
5.1.0
See the version list below for details.
dotnet add package SQLHelper.DB --version 5.1.0
NuGet\Install-Package SQLHelper.DB -Version 5.1.0
<PackageReference Include="SQLHelper.DB" Version="5.1.0" />
<PackageVersion Include="SQLHelper.DB" Version="5.1.0" />
<PackageReference Include="SQLHelper.DB" />
paket add SQLHelper.DB --version 5.1.0
#r "nuget: SQLHelper.DB, 5.1.0"
#:package SQLHelper.DB@5.1.0
#addin nuget:?package=SQLHelper.DB&version=5.1.0
#tool nuget:?package=SQLHelper.DB&version=5.1.0
SQLHelper
SQLHelper is a simple class to help with running queries against a database.
Basic Usage
In order to use the system, you do need register it with your ServiceCollection:
serviceCollection.AddCanisterModules();
This is required prior to using the SQLHelper class for the first time. Once Canister is set up, you can use the SQLHelper class:
var Configuration = new ConfigurationBuilder()
.AddInMemoryCollection()
.Build();
var StringBuilderPool = serviceCollection
.BuildServiceProvider()
.GetService<ObjectPool<StringBuilder>>();
var Instance = new SQLHelper(StringBuilderPool, Configuration);
Or simply ask for an instance using dependency injection:
public MyClass(SQLHelper helper) { ... }
The SQLHelper class takes in an <code>ObjectPool<StringBuilder></code>, an <code>IConfiguration</code>, and an optional logger. Once an instance is set up, you can create a batch, add queries, and then execute them.
var Results = await Instance.CreateBatch()
.AddQuery(CommandType.Text,"SELECT * FROM [TestDatabase].[dbo].[TestTable]")
.AddQuery(CommandType.Text,"SELECT * FROM [TestDatabase].[dbo].[TestTable2]")
.AddQuery(CommandType.Text,"SELECT * FROM [TestDatabase].[dbo].[TestTable3]")
.ExecuteAsync();
The Results object then holds the results for all 3 queries and is returned as IList<IList<dynamic>>. So in order to get the results from the queries:
var FirstQueryResults = Results[0];
var SecondQueryResults = Results[1];
var ThirdQueryResults = Results[2];
It is also possible to convert the results from the dynamic type to a class type that you specify:
var TestTableClasses = FirstQueryResults.Select(x => (TestTableClass)x).ToList();
The type will be converted automatically for you with no special type conversion required. SQLHelper also has an ExecuteScalarAsync function:
var Result = await Instance.ExecuteScalarAsync<int>();
This will either return the first value of the first set of results OR it will return the number of rows that were effected depending on whether or not the query was a select or not.
Installation
The library is available via Nuget with the package name "SQLHelper.DB". To install it run the following command in the Package Manager Console:
Install-Package SQLHelper.DB
Build Process
In order to build the library you will require the following as a minimum:
- Visual Studio 2022
Other than that, just clone the project and you should be able to load the solution and build without too much effort.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 is compatible. 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. |
-
net10.0
- BigBook (>= 6.2.9)
- Microsoft.Data.SqlClient (>= 7.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.7)
- Microsoft.Extensions.ObjectPool (>= 10.0.7)
- Microsoft.SqlServer.Management.SqlParser (>= 173.8.0)
-
net8.0
- BigBook (>= 6.2.9)
- Microsoft.Data.SqlClient (>= 7.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.7)
- Microsoft.Extensions.ObjectPool (>= 10.0.7)
- Microsoft.SqlServer.Management.SqlParser (>= 173.8.0)
-
net9.0
- BigBook (>= 6.2.9)
- Microsoft.Data.SqlClient (>= 7.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.7)
- Microsoft.Extensions.ObjectPool (>= 10.0.7)
- Microsoft.SqlServer.Management.SqlParser (>= 173.8.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SQLHelper.DB:
| Package | Downloads |
|---|---|
|
Data.Modeler
Data.Modeler helps to model database schemas using C#. |
|
|
Holmes
Holmes is a database analysis library designed to suggest improvements and optimizations. Supports .Net Core as well as full .Net. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.1.3 | 227 | 4/29/2026 |
| 5.1.2 | 179 | 4/28/2026 |
| 5.1.1 | 171 | 4/27/2026 |
| 5.1.0 | 99 | 4/26/2026 |
| 5.0.151 | 222 | 4/24/2026 |
| 5.0.150 | 222 | 4/23/2026 |
| 5.0.149 | 199 | 4/22/2026 |
| 5.0.148 | 259 | 4/20/2026 |
| 5.0.147 | 243 | 4/17/2026 |
| 5.0.146 | 200 | 4/16/2026 |
| 5.0.145 | 185 | 4/15/2026 |
| 5.0.144 | 247 | 4/6/2026 |
| 5.0.143 | 263 | 4/1/2026 |
| 5.0.142 | 180 | 3/31/2026 |
| 5.0.141 | 227 | 3/29/2026 |
| 5.0.140 | 105 | 3/29/2026 |
| 5.0.139 | 114 | 3/29/2026 |
| 5.0.138 | 104 | 3/29/2026 |
| 5.0.137 | 150 | 3/29/2026 |
| 5.0.136 | 438 | 3/18/2026 |