Skip to content

DbConnectionProviderDetector

Namespace: MJCZone.DapperMatic.AspNetCore.Factories

Assembly: MJCZone.DapperMatic.AspNetCore

Summary

Utility class for detecting and creating database connections based on connection string characteristics.

static public

Contents

Methods (7)

Methods

MethodSummary
DetectSqlServerProviderDetects the appropriate SQL Server provider (Microsoft.Data.SqlClient vs System.Data.SqlClient) usin...
DetectMySqlProviderDetects the appropriate MySQL provider (MySqlConnector vs MySql.Data) based on explicit Provider=......
DetectSqliteProviderRemoves the "Provider=..." keyword from the connection string.
GetType
ToString
Equals
GetHashCode

DetectSqlServerProvider

Detects the appropriate SQL Server provider (Microsoft.Data.SqlClient vs System.Data.SqlClient) using explicit Provider=..., heuristics, and finally connection string builder parsing.

csharp
DbConnection DetectSqlServerProvider(string connectionString)

Parameters

  • connectionString (string) - The SQL Server connection string.

Returns

Type: DbConnection

An open DbConnection instance.

DetectMySqlProvider

Detects the appropriate MySQL provider (MySqlConnector vs MySql.Data) based on explicit Provider=..., lightweight heuristics, and finally by attempting to parse with each provider's connection-string builder.

csharp
DbConnection DetectMySqlProvider(string connectionString)

Parameters

  • connectionString (string) - The MySQL connection string.

Returns

Type: DbConnection

An open DbConnection instance.

DetectSqliteProvider

Removes the "Provider=..." keyword from the connection string.

csharp
DbConnection DetectSqliteProvider(string connectionString)

Parameters

  • connectionString (string) - The original connection string.

Returns

Type: DbConnection

The cleaned connection string without the provider keyword.

GetType

csharp
GetType()

ToString

csharp
ToString()

Equals

csharp
Equals()

GetHashCode

csharp
GetHashCode()