mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-20 23:56:10 +08:00
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System;
|
|
using System.Data;
|
|
|
|
namespace Dapper
|
|
{
|
|
/// <summary>
|
|
/// Handles variances in features per DBMS
|
|
/// </summary>
|
|
internal class FeatureSupport
|
|
{
|
|
private static readonly FeatureSupport
|
|
Default = new FeatureSupport(false),
|
|
Postgres = new FeatureSupport(true);
|
|
|
|
/// <summary>
|
|
/// Gets the feature set based on the passed connection
|
|
/// </summary>
|
|
/// <param name="connection">The connection to get supported features for.</param>
|
|
public static FeatureSupport Get(IDbConnection connection)
|
|
{
|
|
string name = connection?.GetType().Name;
|
|
if (string.Equals(name, "npgsqlconnection", StringComparison.OrdinalIgnoreCase)) return Postgres;
|
|
return Default;
|
|
}
|
|
|
|
private FeatureSupport(bool arrays)
|
|
{
|
|
Arrays = arrays;
|
|
}
|
|
|
|
/// <summary>
|
|
/// True if the db supports array columns e.g. Postgresql
|
|
/// </summary>
|
|
public bool Arrays { get; }
|
|
}
|
|
}
|