CommonNetFuncs.Sql.Common 3.6.18

dotnet add package CommonNetFuncs.Sql.Common --version 3.6.18
                    
NuGet\Install-Package CommonNetFuncs.Sql.Common -Version 3.6.18
                    
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="CommonNetFuncs.Sql.Common" Version="3.6.18" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CommonNetFuncs.Sql.Common" Version="3.6.18" />
                    
Directory.Packages.props
<PackageReference Include="CommonNetFuncs.Sql.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CommonNetFuncs.Sql.Common --version 3.6.18
                    
#r "nuget: CommonNetFuncs.Sql.Common, 3.6.18"
                    
#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.
#:package CommonNetFuncs.Sql.Common@3.6.18
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CommonNetFuncs.Sql.Common&version=3.6.18
                    
Install as a Cake Addin
#tool nuget:?package=CommonNetFuncs.Sql.Common&version=3.6.18
                    
Install as a Cake Tool

CommonNetFuncs.Sql.Common

nuget

This project contains helper methods for executing SQL queries and commands.

Contents


DirectQuery

Helper methods for executing SQL queries and commands directly against a database.

DirectQuery Usage Examples

<details> <summary><h3>Usage Examples</h3></summary>

GetDataTable

Executes a SELECT query asynchronously and returns the results as a DataTable.

await using SqliteCommand cmd = _connection.CreateCommand();
cmd.CommandText = "SELECT * FROM TestTable";
using DataTable queryResultsTable = await DirectQuery.GetDataTable(connString, cmd); // queryResultsTable will contain the results of the query
GetDataTableSynchronous

Executes a SELECT query synchronously and returns the results as a DataTable.

using SqliteCommand cmd = _connection.CreateCommand();
cmd.CommandText = "SELECT * FROM TestTable";
using DataTable queryResultsTable = DirectQuery.GetDataTable(_connection, cmd); // queryResultsTable will contain the results of the query
RunUpdateQuery

Executes an UPDATE, INSERT, or DELETE query asynchronously and returns an UpdateResult containing the number of affected rows and a boolean indicating success.

await using SqliteCommand cmd = _connection.CreateCommand();
cmd.CommandText = "UPDATE TestTable SET Name = 'Updated' WHERE Name LIKE 'Test%'";
UpdateResult updateResult = await DirectQuery.RunUpdateQuery(_connection, cmd); // { RecordsChanged = 1, Success = true }
RunUpdateQuerySynchronous

Executes an UPDATE, INSERT, or DELETE query synchronously and returns an UpdateResult containing the number of affected rows and a boolean indicating success.

using SqliteCommand cmd = _connection.CreateCommand();
cmd.CommandText = "UPDATE TestTable SET Name = 'Updated' WHERE Name LIKE 'Test%'";
UpdateResult updateResult = DirectQuery.RunUpdateQuery(_connection, cmd); // { RecordsChanged = 1, Success = true }
GetDataStreamSynchronous

Gets a data from a query synchronously and returns an IEnumerable of the query result type.

using SqliteCommand cmd = _connection.CreateCommand();
cmd.CommandText = "SELECT * FROM TestTable";
IEnumerable<TestEntity> queryResults = DirectQuery.GetDataStream(_connection, cmd); // queryResults will contain the results of the query as TestEntity objects
GetDataStreamAsync

Gets a data from a query asynchronously and returns an IAsyncEnumerable of the query result type.

List<TestModel> results = new();
using SqliteCommand cmd = _connection.CreateCommand();
cmd.CommandText = "SELECT * FROM TestTable";
await foreach (TestModel item in DirectQuery.GetDataStreamAsync<TestModel>(_connection, cmd))
{
    results.Add(item); // Results will contain all items returned by the query
}
GetDataDirectAsync

Gets a data from a query asynchronously and returns an IEnumerable of the query result type.

using SqliteCommand cmd = _connection.CreateCommand();
cmd.CommandText = "SELECT * FROM TestTable";
IEnumerable<TestEntity> queryResults = await DirectQuery.GetDataDirectAsync(_connection, cmd); // queryResults will contain the results of the query as TestEntity objects

</details>


QueryParameters

Helper class for cleaning query parameters. Please note that parameter cleaning is not a substitute for proper parameterization of SQL queries. This class is intended to be used in conjunction with parameterized queries to ensure that parameters are clean and safe.

QueryParameters Usage Examples

<details> <summary><h3>Usage Examples</h3></summary>

CleanQueryParam

Cleans potential issues out of a query parameter or query parameters, replacing standalone text "null" with null value or removing any new line characters and extra spaces

"\ntest\n ".CleanQueryParam(); // "test"
IsClean

Checks to make sure that a query parameter does not contain a set of potentially problematic characters / strings including but not limited to: ; ', [, ], ", /*, */ xp_, --, and `

"text[".IsClean(); // false
SanitizeSqlParameter

Sanitizes a SQL parameter by escaping legal but potentially problematic characters or returns and empty string if rules are violated.

string result = "test'name".SanitizeSqlParameter(false, false, false, null, null); // "test''name"
string result = "test;name".SanitizeSqlParameter(false, false, false, null, null); // ""

</details>

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

NuGet packages (4)

Showing the top 4 NuGet packages that depend on CommonNetFuncs.Sql.Common:

Package Downloads
CommonNetFuncs.Web.Interface

Helper methods that deal with ASP.NET Core interfaces

CommonNetFuncs.Sql.Odbc

ODBC driver companion for CommonNetFuncs.Sql.Common

CommonNetFuncs.Sql.PostgreSql

PostgreSQL driver companion for CommonNetFuncs.Sql.Common

CommonNetFuncs.Sql.SqlServer

SQL Server driver companion for CommonNetFuncs.Sql.Common

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.6.18 302 7/25/2025
3.6.6 432 7/21/2025
3.6.1 153 7/14/2025
3.6.0 167 7/14/2025
3.5.3 151 7/10/2025
3.5.0 164 7/7/2025
3.4.23 157 6/26/2025
3.4.21 150 6/26/2025
3.4.20 158 6/25/2025
3.4.18 182 6/23/2025
3.4.14 142 6/17/2025
3.4.9 306 6/11/2025
3.4.8 298 6/11/2025
3.4.2 167 6/2/2025
3.4.1 106 5/30/2025
3.4.0 136 5/30/2025
3.3.11 170 5/19/2025
3.3.10 258 5/13/2025
3.3.0 178 4/29/2025
3.2.22 217 3/12/2025
3.2.14 139 2/20/2025
3.2.13 135 2/13/2025
3.2.9 129 2/4/2025
3.2.6 121 1/28/2025
3.2.0 162 12/19/2024
3.1.0 178 12/6/2024
3.0.0 139 12/3/2024
2.1.3 125 12/3/2024
2.1.2 109 12/3/2024
2.1.0 133 12/2/2024
2.0.5 138 11/26/2024
2.0.2 141 11/18/2024
2.0.1 125 11/15/2024
2.0.0 129 11/14/2024
1.0.47 140 11/14/2024
1.0.42 178 11/12/2024
1.0.40 151 11/12/2024
1.0.37 146 11/4/2024
1.0.31 147 10/31/2024
1.0.28 149 10/25/2024
1.0.26 178 10/18/2024
1.0.25 143 10/17/2024
1.0.24 118 10/17/2024
1.0.18 154 10/11/2024
1.0.17 190 9/27/2024
1.0.16 143 9/27/2024
1.0.14 165 9/23/2024
1.0.13 167 9/18/2024
1.0.12 139 9/18/2024
1.0.11 147 9/18/2024
1.0.10 187 9/11/2024
1.0.9 177 9/11/2024
1.0.8 185 9/11/2024
1.0.7 176 9/11/2024
1.0.2 144 9/10/2024
1.0.1 188 9/4/2024
1.0.0 154 9/2/2024