-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMsSqlConnectionStorage.cs
40 lines (34 loc) · 1.05 KB
/
MsSqlConnectionStorage.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
39
40
using System.Data.SqlClient;
using System.Threading.Tasks;
using SqExpress.DataAccess;
using SqExpress.SqlExport;
namespace SqGoods.DomainLogic.DataAccess
{
internal class MsSqlConnectionStorage : ISqlConnectionStorage
{
private readonly SqlConnection _connection;
public MsSqlConnectionStorage(string connectionString)
{
this._connection = new SqlConnection(connectionString);
}
public ISqDatabase CreateDatabase()
{
return new SqDatabase<SqlConnection>(
connection: this._connection,
commandFactory: (conn, sql) => new SqlCommand(cmdText: sql, connection: conn),
sqlExporter: TSqlExporter.Default);
}
public Task OpenConnectionAsync()
{
return this._connection.OpenAsync();
}
public void Dispose()
{
this._connection.DisposeAsync();
}
public ValueTask DisposeAsync()
{
return this._connection.DisposeAsync();
}
}
}