-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIConnectionFactory.cs
28 lines (26 loc) · 1.34 KB
/
IConnectionFactory.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
using System;
using System.Data;
using System.Threading.Tasks;
namespace RepositoryPattern.Abstractions
{
public abstract class IConnectionFactory : TransactionalUnit
{
public IDbTransaction? CurrentTransaction { get; protected set; }
/// <summary>
/// Open a connection to DB ( if not already open ).
/// </summary>
/// <exception cref="DataRepositoryException"> If the connection timed out or is not accessible </exception>
/// <returns><see cref="IDbConnection"/> object, otherwise throws <see cref="DataRepositoryException"/></returns>
public IDbConnection CreateOpenConnection()
{
return CreateOpenConnectionAsync().ConfigureAwait(false).GetAwaiter().GetResult();
}
/// <summary>
/// Open a connection to DB ( if not already open ) in an async manner.
/// In most connection implementations, this is the default way. i.e. the synchronous version <see cref="CreateOpenConnection"/>, calls async internally.
/// </summary>
/// <exception cref="DataRepositoryException"> If the connection timed out or is not accessible </exception>
/// <returns><see cref="IDbConnection"/> object, otherwise throws <see cref="DataRepositoryException"/></returns>
public abstract Task<IDbConnection> CreateOpenConnectionAsync();
}
}