mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-19 06:31:49 +08:00
46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using System;
|
|
using System.Data;
|
|
#if DNXCORE50
|
|
using IDbDataParameter = global::System.Data.Common.DbParameter;
|
|
using IDataParameter = global::System.Data.Common.DbParameter;
|
|
using IDbTransaction = global::System.Data.Common.DbTransaction;
|
|
using IDbConnection = global::System.Data.Common.DbConnection;
|
|
using IDbCommand = global::System.Data.Common.DbCommand;
|
|
using IDataReader = global::System.Data.Common.DbDataReader;
|
|
using IDataRecord = global::System.Data.Common.DbDataReader;
|
|
using IDataParameterCollection = global::System.Data.Common.DbParameterCollection;
|
|
using DataException = global::System.InvalidOperationException;
|
|
using ApplicationException = global::System.InvalidOperationException;
|
|
#endif
|
|
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 == null ? null : 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; private set; }
|
|
}
|
|
|
|
}
|