Techjrstar.MySqlDbHelper
1.1.1
dotnet add package Techjrstar.MySqlDbHelper --version 1.1.1
NuGet\Install-Package Techjrstar.MySqlDbHelper -Version 1.1.1
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="Techjrstar.MySqlDbHelper" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Techjrstar.MySqlDbHelper" Version="1.1.1" />
<PackageReference Include="Techjrstar.MySqlDbHelper" />
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 Techjrstar.MySqlDbHelper --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Techjrstar.MySqlDbHelper, 1.1.1"
#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 Techjrstar.MySqlDbHelper@1.1.1
#: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=Techjrstar.MySqlDbHelper&version=1.1.1
#tool nuget:?package=Techjrstar.MySqlDbHelper&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Techjrstar.MySqlDbHelper
Techjrstar.MySqlDbHelper is a library that simplifies the execution of stored procedures in MySQL databases using C#.
Installation
You can install this library via NuGet:
Usage
Here's how you can use the library to execute a stored procedure:
using Techjrstar.MySqlDbHelper;
// Create a DbHelper instance
var connectionString = "Server=myServer;Database=myDB;User=myUser;Password=myPassword;";
var dbHelper = new DbHelper(connectionString);
// Define stored procedure parameters
var parameters = new Dictionary<string, object>
{
{ "@_param1", "value1" },
{ "@_param2", 123 },
};
// Execute the store procedute
var result = await dbHelper.ExecuteProcedureAsync("procedure_name", parameters);
// process the results
foreach (var row in result)
{
Console.WriteLine($"Field1: {row["Field1"]}, Field2: {row["Field2"]}");
}
// Execute query
var dbHelper = new DbHelper(connectionString);
var query = "SELECT * FROM vw_view_name";
var result = await dbHelper.ExecuteQueryAsync(query);
// Execute QueryNoAsync
string insertQuery = $"INSERT INTO {tableName} (nombre, edad) VALUES ('Juan', 30)";
int rowsAffected = await dbHelper.ExecuteNonQueryAsync(insertQuery);
if (rowsAffected > 0)
{
Console.WriteLine("Successful Operation");
}
else
{
Console.WriteLine("No rows were affected.");
}
// With Parameters
string query = "UPDATE products SET price = @price WHERE id = @id";
var parameters = new Dictionary<string, object>
{
{ "@price", 19.99 },
{ "@id", 5 }
};
int rowsAffected = await ExecuteNonQueryAsync(query, parameters);
Console.WriteLine($"Rows affected: {rowsAffected}");
// With CancellationToken
using CancellationTokenSource cts = new CancellationTokenSource();
CancellationToken token = cts.Token;
string query = "INSERT INTO orders (customer_id, total) VALUES (@customerId, @total)";
var parameters = new Dictionary<string, object>
{
{ "@customerId", 123 },
{ "@total", 150.75 }
};
// Start a task in another thread to cancel after 1 second (example)
Task.Run(async () =>
{
await Task.Delay(1000);
cts.Cancel(); // Cancel the operation
});
try
{
int result = await ExecuteNonQueryAsync(query, parameters, token);
Console.WriteLine($"Rows inserted: {result}");
}
catch (OperationCanceledException)
{
Console.WriteLine("The operation was canceled.");
}
New function added ExecuteProcedureWithTypedParametersAsync
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 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.
-
net6.0
- MySql.Data (>= 8.2.0)
-
net8.0
- MySql.Data (>= 8.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.