/
PostgreSQLOptions.cs
72 lines (63 loc) · 2.6 KB
/
PostgreSQLOptions.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
namespace LinqToDB.DataProvider.PostgreSQL
{
using Common;
using Common.Internal;
using Data;
/// <param name="BulkCopyType">
/// Default bulk copy mode, used for PostgreSQL by <see cref="DataConnectionExtensions.BulkCopy{T}(DataConnection, IEnumerable{T})"/>
/// methods, if mode is not specified explicitly.
/// Default value: <see cref="BulkCopyType.MultipleRows"/>.
/// </param>
/// <param name="NormalizeTimestampData">
/// Enables normalization of <see cref="DateTime"/> and <see cref="DateTimeOffset"/> data, passed to query
/// as parameter or passed to <see cref="DataConnectionExtensions.BulkCopy{T}(ITable{T}, IEnumerable{T})"/> APIs,
/// to comform with Npgsql 6 requerements:
/// <list type="bullet">
/// <item>convert <see cref="DateTimeOffset"/> value to UTC value with zero <see cref="DateTimeOffset.Offset"/></item>
/// <item>Use <see cref="DateTimeKind.Utc"/> for <see cref="DateTime"/> timestamptz values</item>
/// <item>Use <see cref="DateTimeKind.Unspecified"/> for <see cref="DateTime"/> timestamp values with <see cref="DateTimeKind.Utc"/> kind</item>
/// </list>
/// Default value: <c>true</c>.
/// </param>
/// <param name="IdentifierQuoteMode">
/// Specify identifiers quotation logic for SQL generation.
/// Default value: <see cref="PostgreSQLIdentifierQuoteMode.Auto"/>.
/// </param>
public sealed record PostgreSQLOptions
(
BulkCopyType BulkCopyType = BulkCopyType.MultipleRows,
bool NormalizeTimestampData = true,
PostgreSQLIdentifierQuoteMode IdentifierQuoteMode = PostgreSQLIdentifierQuoteMode.Auto
// If you add another parameter here, don't forget to update
// PostgreSQLOptions copy constructor and CreateID method.
)
: DataProviderOptions<PostgreSQLOptions>(BulkCopyType)
{
public PostgreSQLOptions() : this(BulkCopyType.MultipleRows)
{
}
PostgreSQLOptions(PostgreSQLOptions original) : base(original)
{
NormalizeTimestampData = original.NormalizeTimestampData;
IdentifierQuoteMode = original.IdentifierQuoteMode;
}
protected override IdentifierBuilder CreateID(IdentifierBuilder builder) => builder
.Add(NormalizeTimestampData)
.Add(IdentifierQuoteMode)
;
#region IEquatable implementation
public bool Equals(PostgreSQLOptions? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return ((IOptionSet)this).ConfigurationID == ((IOptionSet)other).ConfigurationID;
}
public override int GetHashCode()
{
return ((IOptionSet)this).ConfigurationID;
}
#endregion
}
}