Search Results for

    Show / Hide Table of Contents

    Class AdbMySqlClientProvider

    A static class where the Get() overloads return AdbProvider immutable instances that wrap the MySql.Data.MySqlClient ADO.NET database provider for accessing MySQL™ and MariaDB™ databases, which assists with writing provider-independent code, mapping between .NET CLR types and database types, etc.

    Use the retrieved AdbProvider instance to create AdbConnectionString, AdbConnectionBuilder, AdbKeepOpenConnectionBuilder and AdbCommandBuilder instances, or pass the provider instance to other methods for them to use it.

    Note that it is best practice to select which provider to use in only one place in the application, to make it easy to switch to a different provider instance, especially since settings such as how to quote identifiers is specified by creating the appropriate provider instance.

    Each AdbProvider instance contains a set of services that implements the provider functionality. You can create a new modified provider instance from an existing one by using its With*() methods to replace one of its services. Custom services can be derived from existing ones, or created from scratch. Alternatively, create a custom provider by using the AdbProvider constructor, specifying all the services.

    This provider uses the following service classes:

    • AdbMySqlClientTypeService
    • AdbMySqlClientTypeMapper
    • AdbMySqlClientTableCommandService
    • AdbMySqlClientDataSourceInformationService
    • AdbSql92InsertStatementService

    Inheritance
    Object
    AdbMySqlClientProvider
    Namespace: actionETL.Adb.MySqlClientExternal
    Assembly: actionETL.dll
    Syntax
    public static class AdbMySqlClientProvider

    Methods

    Get()

    Gets an immutable MySql.Data.MySqlClient AdbProvider instance with default settings for accessing MySQL™ and MariaDB™ databases. It uses the default backtick quote character, i.e. with IdentifierQuotePrefix and IdentifierQuoteSuffix set to `.

    Any AdbInsertTarget<TInputError> will generate multi-row insert statements with DefaultValuesPerTransaction equal to 256, MaxValuesPerBatch equal to 2000, and DefaultValuesPerTransaction equal to 16384.

    Note that with multiple rows per batch or per transaction, any insert error will reject all the rows in the batch or the transaction.

    Also see Server SQL Modes, Schema Object Names, Get(Boolean), and Get(Boolean, Int32, Int32, Int64).

    Declaration
    public static AdbProvider Get()
    Returns
    Type Description
    AdbProvider

    The specified AdbProvider instance.

    Get(Boolean)

    Gets an immutable MySql.Data.MySqlClient AdbProvider instance for accessing MySQL™ and MariaDB™ databases.

    Any AdbInsertTarget<TInputError> will generate multi-row insert statements with DefaultValuesPerTransaction equal to 256, MaxValuesPerBatch equal to 2000, and DefaultValuesPerTransaction equal to 16384.

    Note that with multiple rows per batch or per transaction, any insert error will reject all the rows in the batch or the transaction.

    Also see Server SQL Modes, Schema Object Names, Get(), and Get(Boolean, Int32, Int32, Int64).

    Declaration
    public static AdbProvider Get(bool ansiQuotes)
    Parameters
    Type Name Description
    Boolean ansiQuotes

    Set to false to quote and parse identifiers with the default backtick, i.e. with IdentifierQuotePrefix and IdentifierQuoteSuffix set to `.

    Set to true to use ANSI double quotes (") to quote and parse identifiers, i.e. with IdentifierQuotePrefix and IdentifierQuoteSuffix set to ".

    Also see Server SQL Modes, Schema Object Names, Get(), and Get(Boolean, Int32, Int32, Int64).

    Returns
    Type Description
    AdbProvider

    The specified AdbProvider instance.

    Get(Boolean, Int32, Int32, Int64)

    Gets an immutable MySql.Data.MySqlClient AdbProvider instance for accessing MySQL™ and MariaDB™ databases.

    The batch and transaction parameters control how insert statements for any AdbInsertTarget<TInputError> will be created.

    Inserting multiple rows per batch or per transaction typically increases performance, although using too many parameters can decrease performance, and increases database resource usage.

    Note that with multiple rows per batch or per transaction, any insert error will reject all the rows in the batch or the transaction.

    To use single row inserts that are wrapped in a large transaction for performance, call Get(false, 1, 1, 0).

    To use single row inserts without combining statements in any transaction (e.g. to allow rejecting individual rows), call Get(false, 1, 1, -1).

    Also see Server SQL Modes, Schema Object Names, Get(), and Get(Boolean).

    Declaration
    public static AdbProvider Get(bool ansiQuotes, int defaultValuesPerBatch, int maxValuesPerBatch, long defaultValuesPerTransaction)
    Parameters
    Type Name Description
    Boolean ansiQuotes

    Set to false to quote and parse identifiers with the default backtick, i.e. with IdentifierQuotePrefix and IdentifierQuoteSuffix set to `.

    Set to true to use ANSI double quotes (") to quote and parse identifiers, i.e. with IdentifierQuotePrefix and IdentifierQuoteSuffix set to ".

    Also see Server SQL Modes, Get() and Schema Object Names.

    Int32 defaultValuesPerBatch

    The default number of values (or parameters) per insert batch (or multi-row statement), which determines the default number of rows per batch.

    When set to 0 or less, the default number of parameters per batch is used (currently 256). When set to 1 or greater (e.g. 500), the number of rows is calculated by dividing by the number of values (or parameters) that is processed per row, and using no less than 1 row per batch.

    Int32 maxValuesPerBatch

    The maximum number of values (or parameters) allowed per batch or multi-row insert statement, e.g. 999. Any attempt to set a larger batch size will be automatically limited to this number of values.

    The maximum number of rows per batch is calculated by dividing by the number of values (or parameters) that is processed per row, and using no less than one row per batch.

    Int64 defaultValuesPerTransaction

    The default number of values (or parameters) to use per explicit transaction. This is used to calculate the default number of rows per explicit transaction.

    When set to 1 or greater (e.g. 50000), the number of rows is calculated by dividing by the number of values (or parameters) that is processed per row, and using no less than 1 row per explicit transaction. This means that when set to a very large value (e.g. long.MaxValue), all rows should be inserted wrapped in a single explicit transaction.

    When set to 0, the default number of values (currently 16384) is used.

    When set to less than 0, an explicit transaction should not be created.

    Note that if the connection already has an active transaction, the insert worker should participate in it, irrespective of what this setting is set to.

    Wrapping just one or a few insert statements in a transaction is possible, but typically decreases performance.

    Returns
    Type Description
    AdbProvider

    The specified AdbProvider instance.

    See Also

    MySql.Data.MySqlClient provider article
    AdbConnectionString
    AdbConnectionBuilder
    AdbKeepOpenConnectionBuilder
    AdbCommandBuilder
    AdbProvider
    With(String, IAdbInsertStatementService)
    AdbTableCommand
    IAdbDataSourceInformationService
    IAdbInsertStatementService
    IAdbTypeMapper
    IAdbTypeService
    In This Article
    Back to top Copyright © 2023 Envobi Ltd