MyEasySQL 1.0.2
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 MyEasySQL --version 1.0.2
NuGet\Install-Package MyEasySQL -Version 1.0.2
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="MyEasySQL" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyEasySQL" Version="1.0.2" />
<PackageReference Include="MyEasySQL" />
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 MyEasySQL --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MyEasySQL, 1.0.2"
#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 MyEasySQL@1.0.2
#: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=MyEasySQL&version=1.0.2
#tool nuget:?package=MyEasySQL&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MyEasySQL
MyEasySQL is a lightweight C# library designed to streamline interactions with MySQL databases. It leverages Dapper for efficient data access and provides an intuitive API for performing common operations such as querying, inserting, updating and deleting records. MyEasySQL supports both synchronous and asynchronous operations, providing flexible connection management and optimised query construction for small to large applications.
Nuget
Installation
Run dotnet add package MyEasySQL
Features
- CRUD Operations: Simplified methods for inserting, updating, selecting, and deleting records with optional conditions.
- Database & Table Management: Create and drop databases and tables with a fluent API.
- Dapper Integration: Built on Dapper for efficient data access and object mapping.
- Asynchronous Operations: Perform database operations asynchronously for improved performance.
Example
using MyEasySQL;
using MyEasySQL.Utils;
var sql = new MySQL("host", "name", "user", "password");
// 1. Create a Database
await sql.CreateDatabase("MyDatabase");
// 2. Create a Table
await sql.CreateTable("MyTable")
.AddColumn("ID", DataTypes.INT, autoIncrement: true, primaryKey: true) // Adding a primary key with auto-increment
.AddColumn("Name", DataTypes.VARCHAR, typeValue: "255", notNull: true) // Adding a non-nullable VARCHAR column
.AddColumn("Age", DataTypes.INT) // Adding an integer column for age
.ExecuteAsync(); // Execute the table creation
// 3. Insert Data into the Table
await sql.Insert("MyTable")
.Value("Name", "John Doe") // Inserting the name 'John Doe'
.Value("Age", 30) // Inserting the age 30
.ExecuteAsync();
await sql.Insert("MyTable")
.Value("Name", "Jane Smith") // Inserting the name 'Jane Smith'
.Value("Age", 25) // Inserting the age 25
.ExecuteAsync();
// 4. Update Data in the Table
await sql.Update("MyTable")
.Set("Age", 31) // Updating the age to 31
.Where("Name", Operators.EQUAL, "John Doe") // Where the name is 'John Doe'
.ExecuteAsync();
// 5. Select Data from the Table (SELECT)
var result = await sql.Select("Name", "Age") // Selecting 'Name' and 'Age' columns
.From("MyTable") // From the 'MyTable' table
.Where("Age", Operators.GREATER_THAN, 20) // Where age is greater than 20
.OrderBy("Age", OrderType.ASC) // Ordering by age in ascending order
.Limit(5) // Limiting the results to 5
.ReadAsync<dynamic>(); // Reading the results as dynamic objects
// Iterate through the result and print it
foreach (var row in result)
{
Console.WriteLine($"Name: {row.Name}, Age: {row.Age}");
}
// 6. Delete Data from the Table
await sql.Delete()
.From("MyTable") // From the 'MyTable' table
.Where("Age", Operators.LESS_THAN, 30) // Where age is less than 30
.ExecuteAsync();
// 7. Drop the Table
await sql.DropTable("MyTable"); // Dropping (deleting) the 'MyTable' table
// 8. Drop the Database
await sql.DropDatabase("MyDatabase"); // Dropping (deleting) the 'MyDatabase' database
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 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.
-
net8.0
- Dapper (>= 2.1.35)
- MySqlConnector (>= 2.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.