-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConnectionHelpers.cs
More file actions
31 lines (28 loc) · 730 Bytes
/
ConnectionHelpers.cs
File metadata and controls
31 lines (28 loc) · 730 Bytes
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
public static class ConnectionHelpers
{
#region ConnectionHelpers
public static async Task<SqlConnection> OpenConnection(
string connectionString,
Cancel cancel)
{
var connection = new SqlConnection(connectionString);
try
{
await connection.OpenAsync(cancel);
return connection;
}
catch
{
connection.Dispose();
throw;
}
}
public static async Task<SqlTransaction> BeginTransaction(
string connectionString,
Cancel cancel)
{
var connection = await OpenConnection(connectionString, cancel);
return connection.BeginTransaction();
}
#endregion
}