forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDbDataSource.cs
More file actions
70 lines (50 loc) · 2.34 KB
/
DbDataSource.cs
File metadata and controls
70 lines (50 loc) · 2.34 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#if !NET7_0_OR_GREATER
using System.Threading;
using System.Threading.Tasks;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member (compatibility shim for old TFMs)
// ReSharper disable once CheckNamespace
namespace System.Data.Common;
public abstract class DbDataSource : IDisposable, IAsyncDisposable
{
public abstract string ConnectionString { get; }
protected abstract DbConnection CreateDbConnection();
// No need for an actual implementation in this compat shim - it's only implementation will be NpgsqlDataSource, which overrides this.
protected virtual DbConnection OpenDbConnection()
=> throw new NotSupportedException();
// No need for an actual implementation in this compat shim - it's only implementation will be NpgsqlDataSource, which overrides this.
protected virtual ValueTask<DbConnection> OpenDbConnectionAsync(CancellationToken cancellationToken = default)
=> throw new NotSupportedException();
// No need for an actual implementation in this compat shim - it's only implementation will be NpgsqlDataSource, which overrides this.
protected virtual DbCommand CreateDbCommand(string? commandText = null)
=> throw new NotSupportedException();
// No need for an actual implementation in this compat shim - it's only implementation will be NpgsqlDataSource, which overrides this.
protected virtual DbBatch CreateDbBatch()
=> throw new NotSupportedException();
public DbConnection CreateConnection()
=> CreateDbConnection();
public DbConnection OpenConnection()
=> OpenDbConnection();
public ValueTask<DbConnection> OpenConnectionAsync(CancellationToken cancellationToken = default)
=> OpenDbConnectionAsync(cancellationToken);
public DbCommand CreateCommand(string? commandText = null)
=> CreateDbCommand(commandText);
public DbBatch CreateBatch()
=> CreateDbBatch();
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
public async ValueTask DisposeAsync()
{
await DisposeAsyncCore().ConfigureAwait(false);
Dispose(disposing: false);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
}
protected virtual ValueTask DisposeAsyncCore()
=> default;
}
#endif