Nexd.MySQL
1.0.1
Additional Details
You should use 1.0.2 as of now
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Nexd.MySQL --version 1.0.1
NuGet\Install-Package Nexd.MySQL -Version 1.0.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="Nexd.MySQL" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nexd.MySQL --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Nexd.MySQL, 1.0.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.
// Install Nexd.MySQL as a Cake Addin #addin nuget:?package=Nexd.MySQL&version=1.0.1 // Install Nexd.MySQL as a Cake Tool #tool nuget:?package=Nexd.MySQL&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
C# Sync & Async MySQL (MySqlConnector library) Wrapper
Installation
Available on NuGet
dotnet add package Nexd.MySQL --version 1.0.0
Initialization
// import using
using Nexd.MySQL;
MySqlDb MySql = new MySqlDb("localhost", "root", "password", "database");
Where condition
// WITH WRAPPER CLASSES
MySqlQueryCondition conditions = new MySqlQueryCondition()
.Add("ID", ">", "1002")
.Add("ID", "<=", "1008");
MySqlQueryResult result = MySql.Table("players").Where(conditions).Select();
for(int i = 0; i < result.Rows; i++)
{
Console.WriteLine($"{result.Get<int>(i, "ID")} {result.Get<string>(i, "Name")} {result.Get<string>(i, "Identifier")}");
}
// WITHOUT
MySqlQueryResult result = MySql.Table("players").Where("ID > 1002 AND ID <= 1008").Select();
for(int i = 0; i < result.Rows; i++)
{
Console.WriteLine($"{result.Get<int>(i, "ID")} {result.Get<string>(i, "Name")} {result.Get<string>(i, "Identifier")}");
}
Insert Query
MySqlQueryValue values = new MySqlQueryValue()
.Add("Name", "Player Name #1") // DB column is 'Name', insert data 'Player Name #1'
.Add("Identifier", "uniqueidentifier"); // DB column is 'Identifier', insert data 'uniqueidentifier'
// assume there is a table named 'players'
MySql.Table("players").Insert(values);
Update Query
MySqlQueryValue values = new MySqlQueryValue()
.Add("Name", "Player Name #2");
// with wrapper classes
int rowsAffected = MySql.Table("players").Where(MySqlQueryCondition.New("Identifier", "=", "uniqueidentifier")).Update(values);
// without
int rowsAffected = MySql.Table("players").Where("Identifier = 'uniqueidentifier'").Update(values);
int rowsAffected = MySql.Table("players").Where("Identifier = 'uniqueidentifier' AND ID > 0").Update(values); // random example that shows you can define your where statement just as you like
Select Query
// with wrapper classes
MySqlQueryResult result = MySql.Table("players").Where(MySqlQueryCondition.New("Identifier", "=", "uniqueidentifier")).Select();
// without
MySqlQueryResult result = MySql.Table("players").Where("Identifier = 'uniqueidentifier'").Select(); // you can specify the fields (columns) you want to select, also LIMIT the amount of results by passing them to the .Select() as parameters
// then
int playerId = result.Get<int>(0, "ID"); // 0 is the row, "ID" is the column name in the results
DateTime registeredAt = result.Get<DateTime>(0, "CreationDate"); // 0 is the row, "CreationDate" is the column name in the results
Delete Query
// with wrapper classes
int rowsAffected = MySql.Table("players").Where(MySqlQueryCondition.New("Identifier", "=", "uniqueidentifier")).Delete();
// without
int rowsAffected = MySql.Table("players").Where("Identifier = 'uniqueidentifier'").Delete();
Async
Note: that every method has its Async
version implemented
Documentation is currently unavailable, but its self explanatory and has the same syntax with the sync version, just with Async
method names.
TODO / Missing
- Joins
- Subqueries
- Group by?
- Order by?
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- MySqlConnector (>= 2.2.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.