-
Notifications
You must be signed in to change notification settings - Fork 453
/
DataProviderOptions.cs
51 lines (44 loc) · 1.13 KB
/
DataProviderOptions.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
41
42
43
44
45
46
47
48
49
50
51
using System.Collections.Generic;
namespace LinqToDB.DataProvider
{
using Common;
using Common.Internal;
using Data;
/// <param name="BulkCopyType">
/// Default bulk copy mode, used by <see cref="DataConnectionExtensions.BulkCopy{T}(DataConnection, IEnumerable{T})"/>
/// methods, if mode is not specified explicitly.
/// </param>
public abstract record DataProviderOptions<T>
(
BulkCopyType BulkCopyType
)
: IOptionSet
where T : DataProviderOptions<T>, new()
{
protected DataProviderOptions() : this(BulkCopyType.Default)
{
}
protected DataProviderOptions(DataProviderOptions<T> original)
{
BulkCopyType = original.BulkCopyType;
}
int? _configurationID;
int IConfigurationID.ConfigurationID
{
get
{
if (_configurationID == null)
{
using var idBuilder = new IdentifierBuilder();
_configurationID = CreateID(idBuilder.Add(BulkCopyType)).CreateID();
}
return _configurationID.Value;
}
}
protected abstract IdentifierBuilder CreateID(IdentifierBuilder builder);
/// <summary>
/// Default options.
/// </summary>
public static T Default { get; set; } = new();
}
}