2022-06-30 01:46:41 +02:00
|
|
|
|
using Dapper;
|
2016-02-06 17:09:55 +01:00
|
|
|
|
|
2022-01-11 10:40:51 +01:00
|
|
|
|
namespace Bit.Infrastructure.Dapper.Repositories;
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2022-01-11 10:40:51 +01:00
|
|
|
|
public abstract class BaseRepository
|
2016-02-06 17:09:55 +01:00
|
|
|
|
{
|
|
|
|
|
static BaseRepository()
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2018-05-21 23:12:57 +02:00
|
|
|
|
SqlMapper.AddTypeHandler(new DateTimeHandler());
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-06 17:09:55 +01:00
|
|
|
|
public BaseRepository(string connectionString, string readOnlyConnectionString)
|
|
|
|
|
{
|
2018-05-21 23:12:57 +02:00
|
|
|
|
if (string.IsNullOrWhiteSpace(connectionString))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(connectionString));
|
|
|
|
|
}
|
2018-10-09 23:21:12 +02:00
|
|
|
|
if (string.IsNullOrWhiteSpace(readOnlyConnectionString))
|
2016-02-06 17:09:55 +01:00
|
|
|
|
{
|
2018-10-09 23:21:12 +02:00
|
|
|
|
throw new ArgumentNullException(nameof(readOnlyConnectionString));
|
2016-02-06 17:09:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConnectionString = connectionString;
|
2018-10-09 23:21:12 +02:00
|
|
|
|
ReadOnlyConnectionString = readOnlyConnectionString;
|
2016-02-06 17:09:55 +01:00
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2016-02-06 17:09:55 +01:00
|
|
|
|
protected string ConnectionString { get; private set; }
|
2018-10-09 23:21:12 +02:00
|
|
|
|
protected string ReadOnlyConnectionString { get; private set; }
|
2016-02-06 17:09:55 +01:00
|
|
|
|
}
|