Skip to content

Repository for MySQL specific components for Syrx

License

Notifications You must be signed in to change notification settings

Syrx/Syrx.MySql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

906fd75 · Jan 19, 2025

History

33 Commits
Dec 1, 2024
Jan 19, 2025
Jan 19, 2025
Jan 19, 2025
Nov 22, 2024
Nov 22, 2024
Nov 22, 2024
Jan 19, 2025
Jan 19, 2025
Jan 19, 2025
Dec 1, 2024
Oct 2, 2017

Repository files navigation

Syrx.MySql

This project provides Syrx support for MySql. The overall experience of using Syrx remains the same. The only difference should be during dependency registration.

Installation

Tip

We recommend installing the Extensions package which includes extension methods for easier configuration.

Source Command
.NET CLI dotnet add package Syrx.MySql.Extensions
Package Manager Install-Package Syrx.MySql.Extensions
Package Reference <PackageReference Include="Syrx.MySql.Extensions" Version="2.4.0" />
Paket CLI paket add Syrx.MySql.Extensions --version 2.4.0

However, if you don't need the configuration options, you can install the standalone package via nuget.

Source Command
.NET CLI dotnet add package Syrx.MySql
Package Manager Install-Package Syrx.MySql
Package Reference <PackageReference Include="Syrx.MySql" Version="2.4.0" />
Paket CLI paket add Syrx.MySql --version 2.4.0

Extensions

The Syrx.MySql.Extensions package provides dependency injection support via extension methods.

// add a using statement to the top of the file or in a global usings file.
using Syrx.Commanders.Databases.Connectors.MySql.Extensions;

public static IServiceCollection Install(this IServiceCollection services)
{
    return services
        .UseSyrx(factory => factory         // inject Syrx
        .UseMySql(builder => builder        // using the MySql implementation
            .AddConnectionString(/*...*/)   // add/resolve connection string details 
            .AddCommand(/*...*/)            // add/resolve commands for each type/method
            )
        );
}

Credits

Syrx is inspired by and build on top of Dapper.
MySql support is provided by MySqlConnector.