-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeatureSupport.cs
38 lines (34 loc) · 1.23 KB
/
FeatureSupport.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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),
ClickHouse = 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;
if (string.Equals(name, "clickhouseconnection", StringComparison.OrdinalIgnoreCase)) return ClickHouse;
return Default;
}
private FeatureSupport(bool arrays)
{
Arrays = arrays;
}
/// <summary>
/// True if the db supports array columns e.g. Postgresql
/// </summary>
public bool Arrays { get; }
}
}