You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
953 B

using System;
using System.Data;
namespace Dapper
{
/// <summary>
/// Handles variances in features per DBMS
/// </summary>
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>
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; }
}
}