forked from CirrusRedOrg/EntityFrameworkCore.Jet
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJetIndexExtensions.cs
More file actions
52 lines (48 loc) · 2.49 KB
/
JetIndexExtensions.cs
File metadata and controls
52 lines (48 loc) · 2.49 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 EntityFrameworkCore.Jet.Metadata.Internal;
// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
/// <summary>
/// Extension methods for <see cref="IIndex" /> for Jet-specific metadata.
/// </summary>
public static class JetIndexExtensions
{
/// <summary>
/// Returns included property names, or <c>null</c> if they have not been specified.
/// </summary>
/// <param name="index"> The index. </param>
/// <returns> The included property names, or <c>null</c> if they have not been specified. </returns>
public static IReadOnlyList<string>? GetJetIncludeProperties(this IReadOnlyIndex index)
=> (index is RuntimeIndex)
? throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData)
: (string[]?)index[JetAnnotationNames.Include];
/// <summary>
/// Sets included property names.
/// </summary>
/// <param name="index"> The index. </param>
/// <param name="properties"> The value to set. </param>
public static void SetJetIncludeProperties(this IMutableIndex index, IReadOnlyList<string> properties)
=> index.SetOrRemoveAnnotation(
JetAnnotationNames.Include,
properties);
/// <summary>
/// Sets included property names.
/// </summary>
/// <param name="index"> The index. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <param name="properties"> The value to set. </param>
public static IReadOnlyList<string>? SetJetIncludeProperties(
this IConventionIndex index, IReadOnlyList<string> properties, bool fromDataAnnotation = false)
=> (IReadOnlyList<string>?)index.SetOrRemoveAnnotation(
JetAnnotationNames.Include,
properties,
fromDataAnnotation)?.Value;
/// <summary>
/// Returns the <see cref="ConfigurationSource" /> for the included property names.
/// </summary>
/// <param name="index"> The index. </param>
/// <returns> The <see cref="ConfigurationSource" /> for the included property names. </returns>
public static ConfigurationSource? GetJetIncludePropertiesConfigurationSource(this IConventionIndex index)
=> index.FindAnnotation(JetAnnotationNames.Include)?.GetConfigurationSource();
}
}