-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathNpgsqlForeignKeyBuilderExtensions.cs
More file actions
72 lines (67 loc) · 3.67 KB
/
NpgsqlForeignKeyBuilderExtensions.cs
File metadata and controls
72 lines (67 loc) · 3.67 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
71
72
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore;
/// <summary>
/// Npgsql specific extension methods for configuring foreign keys.
/// </summary>
public static class NpgsqlForeignKeyBuilderExtensions
{
/// <summary>
/// Configure the matching strategy to be used with the foreign key.
/// </summary>
/// <param name="builder">The builder for the foreign key being configured.</param>
/// <param name="matchStrategy">The <see cref="PostgresMatchStrategy" /> defining the used matching strategy.</param>
/// <remarks>
/// <see href="https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-PARMS-REFERENCES" />
/// </remarks>
public static ReferenceReferenceBuilder UsesMatchStrategy(this ReferenceReferenceBuilder builder, PostgresMatchStrategy matchStrategy)
{
Check.NotNull(builder, nameof(builder));
Check.IsDefined(matchStrategy, nameof(matchStrategy));
builder.Metadata.SetMatchStrategy(matchStrategy);
return builder;
}
/// <summary>
/// Configure the matching strategy to be used with the foreign key.
/// </summary>
/// <param name="builder">The builder for the foreign key being configured.</param>
/// <param name="matchStrategy">The <see cref="PostgresMatchStrategy" /> defining the used matching strategy.</param>
/// <remarks>
/// <see href="https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-PARMS-REFERENCES" />
/// </remarks>
public static ReferenceReferenceBuilder<TEntity, TRelatedEntity> UsesMatchStrategy<TEntity, TRelatedEntity>(
this ReferenceReferenceBuilder<TEntity, TRelatedEntity> builder,
PostgresMatchStrategy matchStrategy)
where TEntity : class
where TRelatedEntity : class
=> (ReferenceReferenceBuilder<TEntity, TRelatedEntity>)UsesMatchStrategy((ReferenceReferenceBuilder)builder, matchStrategy);
/// <summary>
/// Configure the matching strategy to be used with the foreign key.
/// </summary>
/// <param name="builder">The builder for the foreign key being configured.</param>
/// <param name="matchStrategy">The <see cref="PostgresMatchStrategy" /> defining the used matching strategy.</param>
/// <remarks>
/// <see href="https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-PARMS-REFERENCES" />
/// </remarks>
public static ReferenceCollectionBuilder UsesMatchStrategy(this ReferenceCollectionBuilder builder, PostgresMatchStrategy matchStrategy)
{
Check.NotNull(builder, nameof(builder));
Check.IsDefined(matchStrategy, nameof(matchStrategy));
builder.Metadata.SetMatchStrategy(matchStrategy);
return builder;
}
/// <summary>
/// Configure the matching strategy to be used with the foreign key.
/// </summary>
/// <param name="builder">The builder for the foreign key being configured.</param>
/// <param name="matchStrategy">The <see cref="PostgresMatchStrategy" /> defining the used matching strategy.</param>
/// <remarks>
/// <see href="https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-PARMS-REFERENCES" />
/// </remarks>
public static ReferenceCollectionBuilder UsesMatchStrategy<TEntity, TRelatedEntity>(
this ReferenceCollectionBuilder<TEntity, TRelatedEntity> builder,
PostgresMatchStrategy matchStrategy)
where TEntity : class
where TRelatedEntity : class
=> (ReferenceCollectionBuilder<TEntity, TRelatedEntity>)UsesMatchStrategy((ReferenceCollectionBuilder)builder, matchStrategy);
}