SQLHelper.DB 5.0.23

There is a newer version of this package available.
See the version list below for details.
dotnet add package SQLHelper.DB --version 5.0.23                
NuGet\Install-Package SQLHelper.DB -Version 5.0.23                
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="SQLHelper.DB" Version="5.0.23" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SQLHelper.DB --version 5.0.23                
#r "nuget: SQLHelper.DB, 5.0.23"                
#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 SQLHelper.DB as a Cake Addin
#addin nuget:?package=SQLHelper.DB&version=5.0.23

// Install SQLHelper.DB as a Cake Tool
#tool nuget:?package=SQLHelper.DB&version=5.0.23                

SQLHelper

Build status

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 Instance = new SQLHelper(Configuration, SqlClientFactory.Instance, "ConnectionString");

Or simply ask for an instance using dependency injection:

public MyClass(SQLHelper helper) { ... }

The SQLHelper class takes in a IConfiguration class, a DbProviderFactory class, and the connection string. The connection string can just be the name of a connection string in your configuration object. Once an instance is set up, you can create a batch, add queries, and then execute them.

var Results = 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]")
            		   .Execute();
					   

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 ExecuteScalar function:

var Result = Instance.ExecuteScalar<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:

  1. 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 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.27 121 6 days ago
5.0.25 209 15 days ago
5.0.24 120 19 days ago
5.0.23 99 20 days ago
5.0.22 144 25 days ago
5.0.21 151 a month ago
5.0.20 193 a month ago
5.0.19 97 a month ago
5.0.15 125 a month ago
5.0.14 105 a month ago
5.0.13 356 2 months ago
5.0.12 236 2 months ago
5.0.11 97 2 months ago
5.0.10 90 2 months ago
5.0.9 147 2 months ago
5.0.8 309 3 months ago
5.0.7 90 3 months ago
5.0.6 230 3 months ago
5.0.5 97 3 months ago
5.0.4 126 3 months ago
4.0.218 181 3 months ago
4.0.217 130 3 months ago
4.0.216 265 3 months ago
4.0.215 153 3 months ago
4.0.214 227 3 months ago
4.0.213 152 3 months ago
4.0.212 165 4 months ago
4.0.211 147 4 months ago
4.0.210 148 4 months ago
4.0.209 145 4 months ago
4.0.208 202 4 months ago
4.0.207 219 4 months ago
4.0.206 195 4 months ago
4.0.205 206 4 months ago
4.0.204 156 4 months ago
4.0.203 152 4 months ago
4.0.202 230 5 months ago
4.0.201 162 5 months ago
4.0.200 188 5 months ago
4.0.199 220 5 months ago
4.0.198 183 5 months ago
4.0.197 236 5 months ago
4.0.196 242 5 months ago
4.0.195 237 5 months ago
4.0.194 252 5 months ago
4.0.193 229 6 months ago
4.0.192 176 6 months ago
4.0.191 173 6 months ago
4.0.190 184 6 months ago
4.0.189 198 6 months ago
4.0.188 201 6 months ago
4.0.187 266 6 months ago
4.0.186 374 6 months ago
4.0.185 182 6 months ago
4.0.184 193 6 months ago
4.0.183 187 6 months ago
4.0.182 152 7 months ago
4.0.181 168 7 months ago
4.0.180 242 7 months ago
4.0.179 182 7 months ago
4.0.178 244 7 months ago
4.0.177 170 7 months ago
4.0.176 115 7 months ago
4.0.175 199 7 months ago
4.0.174 304 7 months ago
4.0.173 226 8 months ago
4.0.172 272 8 months ago
4.0.171 183 8 months ago
4.0.170 253 8 months ago
4.0.169 1,101 8 months ago
4.0.168 194 8 months ago
4.0.167 198 8 months ago
4.0.166 206 8 months ago
4.0.165 178 8 months ago
4.0.164 303 8 months ago
4.0.163 203 9 months ago
4.0.162 197 9 months ago
4.0.161 184 9 months ago
4.0.160 314 9 months ago
4.0.159 236 9 months ago
4.0.158 253 9 months ago
4.0.157 226 9 months ago
4.0.156 186 9 months ago
4.0.155 188 9 months ago
4.0.154 236 9 months ago
4.0.153 196 9 months ago
4.0.152 207 9 months ago
4.0.151 191 9 months ago
4.0.150 726 10 months ago
4.0.149 209 10 months ago
4.0.148 198 10 months ago
4.0.147 239 10 months ago
4.0.146 220 10 months ago
4.0.145 285 4/16/2024
4.0.144 206 4/12/2024
4.0.143 173 4/12/2024
4.0.142 195 4/11/2024
4.0.141 212 4/10/2024
4.0.140 193 4/9/2024
4.0.139 269 4/1/2024
4.0.138 236 3/29/2024
4.0.137 226 3/26/2024
4.0.136 210 3/22/2024
4.0.135 117 3/22/2024
4.0.134 255 3/18/2024
4.0.133 200 3/15/2024
4.0.132 185 3/14/2024
4.0.131 221 3/13/2024
4.0.130 215 3/11/2024
4.0.129 193 3/8/2024
4.0.128 167 3/7/2024
4.0.127 139 3/6/2024
4.0.126 151 3/5/2024
4.0.125 151 3/4/2024
4.0.124 1,258 3/1/2024
4.0.123 206 2/29/2024
4.0.122 116 2/28/2024
4.0.121 155 2/27/2024
4.0.120 306 2/26/2024
4.0.119 118 2/23/2024
4.0.118 142 2/22/2024
4.0.117 124 2/21/2024
4.0.116 139 2/20/2024
4.0.115 123 2/20/2024
4.0.114 739 2/19/2024
4.0.113 131 2/19/2024
4.0.112 210 2/16/2024
4.0.111 125 2/15/2024
4.0.110 149 2/14/2024
4.0.109 328 2/13/2024
4.0.108 203 2/12/2024
4.0.107 146 2/9/2024
4.0.106 236 2/8/2024
4.0.105 116 2/7/2024
4.0.104 107 2/7/2024
4.0.103 117 2/6/2024
4.0.102 696 2/2/2024
4.0.101 171 2/1/2024
4.0.100 122 2/1/2024
4.0.99 124 1/31/2024
4.0.98 121 1/30/2024
4.0.97 458 1/25/2024
4.0.96 172 1/24/2024
4.0.95 130 1/23/2024
4.0.94 1,204 1/16/2024
4.0.93 120 1/16/2024
4.0.92 208 1/15/2024
4.0.91 215 1/12/2024
4.0.90 129 1/11/2024
4.0.89 130 1/10/2024
4.0.88 495 1/8/2024
4.0.87 597 12/26/2023
4.0.86 121 12/26/2023
4.0.85 126 12/25/2023
4.0.84 370 12/22/2023
4.0.83 310 12/15/2023
4.0.82 126 12/14/2023
4.0.81 110 12/14/2023
4.0.80 148 12/13/2023
4.0.79 129 12/12/2023
4.0.78 819 12/11/2023
4.0.77 306 12/6/2023
4.0.76 262 12/5/2023
4.0.75 417 11/24/2023
4.0.74 287 11/21/2023
4.0.73 255 11/20/2023
4.0.72 203 11/20/2023
4.0.71 230 11/17/2023
4.0.70 612 11/16/2023
4.0.69 212 11/14/2023
4.0.68 298 11/9/2023
4.0.67 250 11/8/2023
4.0.66 215 11/7/2023
4.0.65 211 11/6/2023
4.0.64 220 11/3/2023
4.0.63 308 11/1/2023
4.0.62 137 11/1/2023
4.0.61 250 10/31/2023
4.0.60 229 10/30/2023
4.0.59 220 10/27/2023
4.0.58 209 10/26/2023
4.0.57 218 10/25/2023
4.0.56 218 10/17/2023
4.0.55 273 10/16/2023
4.0.54 298 10/12/2023
4.0.53 211 10/11/2023
4.0.52 259 10/5/2023
4.0.51 300 9/26/2023
4.0.50 298 9/22/2023
4.0.49 222 9/20/2023
4.0.48 205 9/19/2023
4.0.47 130 9/19/2023
4.0.46 251 9/18/2023
4.0.45 298 9/14/2023
4.0.44 219 9/13/2023
4.0.43 222 9/12/2023
4.0.42 259 9/11/2023
4.0.41 149 9/11/2023
4.0.40 218 9/11/2023
4.0.39 385 9/7/2023
4.0.38 222 9/6/2023
4.0.37 277 9/5/2023
4.0.36 162 9/5/2023
4.0.35 254 9/4/2023
4.0.34 295 9/1/2023
4.0.33 280 8/31/2023
4.0.32 246 8/30/2023
4.0.31 151 8/30/2023
4.0.30 275 8/29/2023
4.0.29 407 8/25/2023
4.0.28 341 8/23/2023
4.0.27 346 8/18/2023
4.0.26 231 8/17/2023
4.0.25 142 8/17/2023
4.0.24 148 8/17/2023
4.0.23 460 8/10/2023
4.0.22 255 8/9/2023
4.0.21 231 8/8/2023
4.0.20 169 8/8/2023
4.0.19 308 8/8/2023
4.0.18 373 8/7/2023
4.0.17 464 8/3/2023
4.0.16 396 7/26/2023
4.0.15 360 7/20/2023
4.0.14 367 7/18/2023
4.0.13 174 7/18/2023
4.0.12 161 7/18/2023
4.0.11 598 7/17/2023
4.0.10 175 7/14/2023
4.0.9 174 7/13/2023
4.0.8 164 7/13/2023
4.0.7 180 7/12/2023
4.0.6 174 7/12/2023
4.0.5 226 6/13/2023
4.0.4 1,011 1/30/2023
4.0.3 532 1/30/2023
4.0.2 537 1/27/2023
4.0.1 706 12/13/2022
4.0.0 517 12/12/2022
3.1.49 2,671 6/10/2022
3.1.47 1,817 4/20/2022
3.1.46 803 2/25/2022
3.1.45 2,014 1/11/2022
3.1.44 1,082 1/10/2022
3.1.43 1,137 10/12/2021
3.1.42 456 10/12/2021
3.1.41 1,665 6/17/2021
3.1.40 1,277 6/16/2021
3.1.39 1,159 6/16/2021
3.1.38 972 6/16/2021
3.1.37 742 6/15/2021
3.1.35 1,918 1/7/2021
3.1.34 1,378 12/16/2020
3.1.33 575 12/16/2020
3.1.32 1,184 12/14/2020
3.1.31 3,216 9/13/2020
3.1.30 1,692 6/19/2020
3.1.29 1,154 6/8/2020
3.1.28 2,446 5/12/2020
3.1.27 1,924 5/12/2020
3.1.26 1,440 4/28/2020
3.1.25 1,395 4/16/2020
3.1.23 1,345 4/16/2020
3.1.22 1,386 4/16/2020
3.1.21 1,125 4/15/2020
3.1.20 1,351 4/15/2020
3.1.19 1,426 4/14/2020
3.1.18 1,126 4/14/2020
3.1.17 612 4/14/2020
3.1.16 1,424 4/10/2020
3.1.15 1,443 4/10/2020
3.1.14 3,874 3/26/2020
3.1.13 1,460 3/26/2020
3.1.12 1,646 3/25/2020
3.1.11 1,134 3/25/2020
3.1.10 1,120 3/25/2020
3.1.9 1,566 3/25/2020
3.1.8 1,642 3/24/2020
3.1.7 2,258 3/21/2020
3.1.6 2,154 3/13/2020
3.1.5 1,151 3/13/2020
3.1.3 2,115 2/28/2020
3.1.1.2 615 2/28/2020
3.1.1 936 2/22/2020
3.1.0 1,176 2/21/2020
3.0.4 1,235 2/11/2020
3.0.3 897 2/11/2020
3.0.2 684 2/10/2020
3.0.1 1,640 1/9/2020
3.0.0 1,368 12/23/2019
2.0.18 2,473 6/19/2019
2.0.17 693 6/19/2019
2.0.16 2,113 4/17/2019
2.0.15 1,542 3/14/2019
2.0.14 753 2/22/2019
2.0.13 1,749 2/21/2019
2.0.12 727 2/21/2019
2.0.11 4,480 8/1/2018
2.0.10 1,656 8/1/2018
2.0.9 1,324 7/3/2018
2.0.8 1,802 6/26/2018
2.0.7 1,051 6/26/2018
2.0.6 1,594 6/14/2018
2.0.5 1,686 6/1/2018
2.0.4 1,978 5/22/2018
2.0.3 2,586 5/9/2018
2.0.2 2,251 2/15/2018
2.0.1 1,900 2/13/2018
2.0.0 2,611 1/2/2018
1.0.44 11,225 10/10/2017
1.0.42 945 10/10/2017
1.0.41 1,252 9/29/2017
1.0.40 4,237 9/19/2017
1.0.39 966 9/15/2017
1.0.36 954 9/15/2017
1.0.35 943 9/15/2017
1.0.34 3,213 7/3/2017
1.0.33 1,811 6/16/2017
1.0.32 1,770 6/16/2017
1.0.31 1,008 5/30/2017
1.0.28 1,661 5/30/2017
1.0.27 1,459 5/25/2017
1.0.26 1,729 5/24/2017
1.0.25 1,313 5/19/2017
1.0.24 1,002 5/19/2017
1.0.23 1,294 5/17/2017
1.0.20 1,101 5/8/2017
1.0.19 1,146 4/7/2017
1.0.18 1,701 3/22/2017
1.0.15 1,439 1/31/2017
1.0.14 1,123 1/24/2017
1.0.13 1,141 1/8/2017
1.0.12 1,110 1/6/2017
1.0.11 1,129 1/6/2017
1.0.10 1,097 1/3/2017
1.0.9 1,224 12/9/2016
1.0.8 1,049 12/1/2016
1.0.0 1,033 9/15/2017