-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSqlDbStorage.cs
36 lines (32 loc) · 1.05 KB
/
SqlDbStorage.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
using Microsoft.Data.SqlClient;
using RepoDb;
using RepoDB.Trials.Business.Interfaces;
using RepoDB.Trials.Core;
using System;
using System.Collections.Generic;
using System.Text;
namespace RepoDB.Trials.Business.Repositories
{
public class SqlDbStorage:DbRepository<SqlConnection>,IStorage
{
private Dictionary<Type, object> repositories;
private readonly IAppSettings settings;
public SqlDbStorage(IAppSettings settings): base(settings.ConnectionString, settings.CommandTimeout)
{
this.settings = settings;
if (this.repositories == null)
{
this.repositories = new Dictionary<Type, object>();
}
}
public BasicRepository<T> GetRepository<T>() where T:BaseEntity
{
var type = typeof(T);
if (!this.repositories.ContainsKey(type))
{
this.repositories[type] = new BasicRepository<T>(settings);
}
return (BasicRepository<T>)this.repositories[type];
}
}
}