Unleasharp.DB.MySQL
1.0.0
See the version list below for details.
dotnet add package Unleasharp.DB.MySQL --version 1.0.0
NuGet\Install-Package Unleasharp.DB.MySQL -Version 1.0.0
<PackageReference Include="Unleasharp.DB.MySQL" Version="1.0.0" />
<PackageVersion Include="Unleasharp.DB.MySQL" Version="1.0.0" />
<PackageReference Include="Unleasharp.DB.MySQL" />
paket add Unleasharp.DB.MySQL --version 1.0.0
#r "nuget: Unleasharp.DB.MySQL, 1.0.0"
#:package Unleasharp.DB.MySQL@1.0.0
#addin nuget:?package=Unleasharp.DB.MySQL&version=1.0.0
#tool nuget:?package=Unleasharp.DB.MySQL&version=1.0.0
🐬 Unleasharp.DB.MySQL
MySQL implementation of Unleasharp.DB.Base. This repository provides a MySQL-specific implementation that leverages the base abstraction layer for common database operations.
📦 Installation
Install the NuGet package using one of the following methods:
Package Manager Console
Install-Package Unleasharp.DB.MySQL
.NET CLI
dotnet add package Unleasharp.DB.MySQL
PackageReference (Manual)
<PackageReference Include="Unleasharp.DB.MySQL" Version="1.0.0" />
🎯 Features
- MySQL-Specific Query Rendering: Custom query building and rendering tailored for MySQL
- Connection Management: Robust connection handling through ConnectorManager
- Query Builder Integration: Seamless integration with the base QueryBuilder
- Schema Definition Support: Full support for table and column attributes
🚀 Connection Initialization
The ConnectorManager
handles database connections. You can initialize it using a connection string or MySqlConnectionStringBuilder
.
Using Connection String
ConnectorManager DBConnector = new ConnectorManager("Server=localhost;Database=unleasharp;Uid=unleasharp;Pwd=unleasharp;");
Using Fluent Configuration
ConnectorManager DBConnector = new ConnectorManager()
.WithAutomaticConnectionRenewal(true)
.WithAutomaticConnectionRenewalInterval(TimeSpan.FromHours(1))
.Configure(config => {
config.ConnectionString = "Server=localhost;Database=unleasharp;Uid=unleasharp;Pwd=unleasharp;";
});
Using MySqlConnectionStringBuilder
ConnectorManager DBConnector = new ConnectorManager(
new MySqlConnectionStringBuilder("Server=localhost;Database=unleasharp;Uid=unleasharp;Pwd=unleasharp;")
);
📝 Usage Examples
Sample Table Structure
using System.ComponentModel;
using Unleasharp.DB.Base.SchemaDefinition;
namespace Unleasharp.DB.MySQL.Sample;
[Table("example_table")]
[Key("id", Field = "id", KeyType = Unleasharp.DB.Base.QueryBuilding.KeyType.PRIMARY)]
public class ExampleTable
{
[Column("id", "bigint", Unsigned = true, PrimaryKey = true, AutoIncrement = true, NotNull = true, Length = 20)]
public ulong? ID { get; set; }
[Column("_mediumtext", "mediumtext")]
public string MediumText { get; set; }
[Column("_longtext", "longtext")]
public string _longtext { get; set; }
[Column("_json", "longtext")]
public string _json { get; set; }
[Column("_longblob", "longblob")]
public byte[] CustomFieldName { get; set; }
[Column("_enum", "enum")]
public EnumExample? _enum { get; set; }
[Column("_varchar", "varchar", Length = 255)]
public string _varchar { get; set; }
}
public enum EnumExample
{
NONE,
Y,
[Description("NEGATIVE")]
N
}
Sample Program
using System;
using System.Collections.Generic;
using Unleasharp.DB.MySQL;
using Unleasharp.DB.Base.QueryBuilding;
namespace Unleasharp.DB.MySQL.Sample;
internal class Program
{
static void Main(string[] args)
{
// Initialize database connection
ConnectorManager DBConnector = new ConnectorManager("Server=192.168.1.8;Database=unleasharp;Uid=unleasharp;Pwd=unleasharp;");
// Create table
DBConnector.QueryBuilder().Build(Query => Query.Create<ExampleTable>()).Execute();
// Insert data
DBConnector.QueryBuilder().Build(Query => { Query
.From<ExampleTable>()
.Value(new ExampleTable {
MediumText = "Medium text example value",
_enum = EnumExample.N
})
.Values(new List<ExampleTable> {
new ExampleTable {
_json = @"{""sample_json_field"": ""sample_json_value""}",
_enum = EnumExample.Y,
CustomFieldName = new byte[8] { 81,47,15,21,12,16,23,39 }
},
new ExampleTable {
_longtext = "Long text example value",
ID = 999 // RandomID placeholder
}
})
.Insert();
}).Execute();
// Select single row
ExampleTable Row = DBConnector.QueryBuilder().Build(Query => Query
.From("example_table")
.OrderBy("id", OrderDirection.ASC)
.Limit(1)
.Select()
).FirstOrDefault<ExampleTable>();
// Select multiple rows with different class naming
List<example_table> Rows = DBConnector.QueryBuilder().Build(Query => Query
.From("example_table")
.OrderBy("id", OrderDirection.DESC)
.Select()
).ToList<example_table>();
}
}
Sample Query Rendering
// Complex query demonstration with subqueries
Query VeryComplexQuery = Query.GetInstance()
.Select("query_field")
.Select($"COUNT({new FieldSelector("table_x", "table_y")})", true)
.From("query_from")
.Where("field", "value")
.WhereIn(
"field_list",
Query.GetInstance()
.Select("*", false)
.From("subquery_table")
.Where("subquery_field", true)
.WhereIn(
"subquery_in_field",
Query.GetInstance()
.Select("subquery_subquery_in_field")
.From("subquery_subquery_in_table")
.Where("subquery_subquery_in_where", true)
)
.Limit(100)
)
.WhereIn("field_list", new List<dynamic> { null, 123, 456, "789" })
.Join("another_table", new FieldSelector("table_x", "field_x"), new FieldSelector("table_y", "field_y"))
.OrderBy(new OrderBy {
Field = new FieldSelector("order_field"),
Direction = OrderDirection.DESC
})
.GroupBy("group_first")
.GroupBy("group_second")
.Limit(100);
// Render raw SQL query
Console.WriteLine(VeryComplexQuery.Render());
// Render prepared statement query (with placeholders)
Console.WriteLine(VeryComplexQuery.RenderPrepared());
📦 Dependencies
- Unleasharp.DB.Base - Base abstraction layer
- MySqlConnector - MySQL driver for .NET
📋 Version Compatibility
This library targets .NET 8.0 and later versions. For specific version requirements, please check the package dependencies.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
For more information about Unleasharp.DB.Base, visit: Unleasharp.DB.Base
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. |
-
net8.0
- MySqlConnector (>= 2.4.0)
- Unleasharp.DB.Base (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.8.4 | 155 | 10/2/2025 |
1.8.3 | 188 | 9/22/2025 |
1.8.2 | 207 | 9/21/2025 |
1.8.0 | 206 | 9/19/2025 |
1.7.1 | 274 | 9/15/2025 |
1.7.0 | 153 | 9/11/2025 |
1.6.0 | 156 | 9/3/2025 |
1.5.5 | 148 | 9/1/2025 |
1.5.3 | 152 | 8/31/2025 |
1.5.2 | 170 | 8/30/2025 |
1.5.0 | 197 | 8/28/2025 |
1.4.1 | 198 | 8/28/2025 |
1.4.0 | 197 | 8/28/2025 |
1.3.1 | 211 | 8/26/2025 |
1.3.0 | 154 | 8/25/2025 |
1.2.0 | 81 | 8/22/2025 |
1.1.1 | 144 | 8/21/2025 |
1.1.0 | 149 | 8/20/2025 |
1.0.2 | 149 | 8/20/2025 |
1.0.1 | 151 | 8/20/2025 |
1.0.0 | 151 | 8/19/2025 |