Repository navigation
Expand file tree
/
Copy pathSQLite.TableCopyAdapter.ConnectionConfiguration.cs
More file actions
52 lines (45 loc) · 2.04 KB
/
Copy pathSQLite.TableCopyAdapter.ConnectionConfiguration.cs
File metadata and controls
52 lines (45 loc) · 2.04 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
using Microsoft.Data.Sqlite;
namespace DBAClientX;
public sealed partial class SQLiteTableCopyAdapter
{
private volatile SQLiteConnectionOptions? _connectionOptions;
private volatile Action<SqliteConnection>? _configureConnection;
/// <summary>Gets or sets the shared SQLite operational profile for adapter connections.</summary>
/// <remarks>
/// Profiles are copied on assignment and retrieval. Configure the adapter before starting a copy.
/// Null retains the existing provider defaults. The profile applies to reads, writes, schema preflight,
/// verification and atomic checkpoints; read-only connections skip write pragmas.
/// </remarks>
public SQLiteConnectionOptions? ConnectionOptions
{
get => _connectionOptions?.Snapshot();
set => _connectionOptions = value?.Snapshot();
}
/// <summary>Gets or sets registrations applied before the first SQL command on every adapter connection.</summary>
/// <remarks>
/// Register functions and collations used by views, indexes and triggers here, for example
/// <see cref="SQLiteUnicodeText.Register(SqliteConnection)"/>. The callback must be thread-safe.
/// A callback failure aborts the operation and the connection is disposed.
/// </remarks>
public Action<SqliteConnection>? ConfigureConnection
{
get => _configureConnection;
set => _configureConnection = value;
}
private SQLite CreateClient() => new()
{
CommandTimeout = CommandTimeout,
ConnectionOptions = _connectionOptions,
ConfigureConnection = _configureConnection
};
private SqliteConnection CreateConnection()
{
using var client = CreateClient();
return client.CreateConfiguredConnection(ResolveSQLiteConnectionString());
}
private async Task OpenConnectionAsync(SqliteConnection connection, CancellationToken cancellationToken)
{
using var client = CreateClient();
await client.OpenConfiguredConnectionAsync(connection, cancellationToken).ConfigureAwait(false);
}
}