Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata: Add HasField(FieldInfo) on NavigationBuilder #21550

Merged
1 commit merged into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EFCore.Relational/Metadata/Internal/TableMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public TableMapping(
}

/// <inheritdoc/>
new public virtual ITable Table => (ITable)base.Table;
public new virtual ITable Table => (ITable)base.Table;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
92 changes: 0 additions & 92 deletions src/EFCore/Metadata/Builders/IConventionForeignKeyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,98 +297,6 @@ bool CanSetNavigations(
[CanBeNull] MemberInfo navigationToDependent,
bool fromDataAnnotation = false);

/// <summary>
/// Sets the backing field to use for a navigation.
/// </summary>
/// <param name="fieldName"> The field name. </param>
/// <param name="pointsToPrincipal">
/// A value indicating whether the navigation is on the dependent type pointing to the principal type.
/// </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns>
/// The same builder instance if the configuration was applied,
/// <see langword="null" /> otherwise.
/// </returns>
IConventionForeignKeyBuilder HasField(
[CanBeNull] string fieldName,
bool pointsToPrincipal,
bool fromDataAnnotation = false);

/// <summary>
/// Sets the backing field to use for a navigation.
/// </summary>
/// <param name="fieldInfo"> The field. </param>
/// <param name="pointsToPrincipal">
/// A value indicating whether the navigation is on the dependent type pointing to the principal type.
/// </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns>
/// The same builder instance if the configuration was applied,
/// <see langword="null" /> otherwise.
/// </returns>
IConventionForeignKeyBuilder HasField(
[CanBeNull] FieldInfo fieldInfo,
bool pointsToPrincipal,
bool fromDataAnnotation = false);

/// <summary>
/// Returns a value indicating whether the backing field can be set for a navigation
/// from the given configuration source.
/// </summary>
/// <param name="fieldName"> The field name. </param>
/// <param name="pointsToPrincipal">
/// A value indicating whether the navigation is on the dependent type pointing to the principal type.
/// </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> <see langword="true" /> if the backing field can be set for this property. </returns>
bool CanSetField(
[CanBeNull] string fieldName,
bool pointsToPrincipal,
bool fromDataAnnotation = false);

/// <summary>
/// Returns a value indicating whether the backing field can be set for a navigation
/// from the given configuration source.
/// </summary>
/// <param name="fieldInfo"> The field. </param>
/// <param name="pointsToPrincipal">
/// A value indicating whether the navigation is on the dependent type pointing to the principal type.
/// </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> <see langword="true" /> if the backing field can be set for this property. </returns>
bool CanSetField(
[CanBeNull] FieldInfo fieldInfo,
bool pointsToPrincipal,
bool fromDataAnnotation = false);

/// <summary>
/// Sets the <see cref="PropertyAccessMode" /> to use for a navigation.
/// </summary>
/// <param name="propertyAccessMode"> The <see cref="PropertyAccessMode" /> to use for the navigation. </param>
/// <param name="pointsToPrincipal">
/// A value indicating whether the navigation is on the dependent type pointing to the principal type.
/// </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns>
/// The same builder instance if the configuration was applied,
/// <see langword="null" /> otherwise.
/// </returns>
IConventionForeignKeyBuilder UsePropertyAccessMode(
PropertyAccessMode? propertyAccessMode, bool pointsToPrincipal, bool fromDataAnnotation = false);

/// <summary>
/// Returns a value indicating whether the <see cref="PropertyAccessMode" /> can be set for a navigation
/// from the given configuration source.
/// </summary>
/// <param name="propertyAccessMode"> The <see cref="PropertyAccessMode" /> to use for the navigation. </param>
/// <param name="pointsToPrincipal">
/// A value indicating whether the navigation is on the dependent type pointing to the principal type.
/// </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> <see langword="true" /> if the <see cref="PropertyAccessMode" /> can be set for this property. </returns>
bool CanSetPropertyAccessMode(
PropertyAccessMode? propertyAccessMode, bool pointsToPrincipal, bool fromDataAnnotation = false);

/// <summary>
/// Configures whether this is a required relationship (i.e. whether none the foreign key properties can
/// be assigned <see langword="null" />).
Expand Down
21 changes: 21 additions & 0 deletions src/EFCore/Metadata/Builders/IConventionNavigationBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Reflection;
using JetBrains.Annotations;

namespace Microsoft.EntityFrameworkCore.Metadata.Builders
Expand Down Expand Up @@ -41,6 +42,26 @@ public interface IConventionNavigationBuilder : IConventionAnnotatableBuilder
/// </returns>
IConventionNavigationBuilder HasField([CanBeNull] string fieldName, bool fromDataAnnotation = false);

/// <summary>
/// Returns a value indicating whether the backing field can be set for this navigation
/// from the given configuration source.
/// </summary>
/// <param name="fieldInfo"> The field. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> <see langword="true" /> if the backing field can be set for this property. </returns>
bool CanSetField([CanBeNull] FieldInfo fieldInfo, bool fromDataAnnotation = false);

/// <summary>
/// Sets the backing field to use for this navigation.
/// </summary>
/// <param name="fieldInfo"> The field. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns>
/// The same builder instance if the configuration was applied,
/// <see langword="null" /> otherwise.
/// </returns>
IConventionNavigationBuilder HasField([CanBeNull] FieldInfo fieldInfo, bool fromDataAnnotation = false);

/// <summary>
/// Returns a value indicating whether the <see cref="PropertyAccessMode" /> can be set for this navigation
/// from the current configuration source.
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Metadata/Conventions/BackingFieldConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public virtual void ProcessNavigationAdded(
var field = GetFieldToSet(navigation);
if (field != null)
{
navigation.ForeignKey.Builder.HasField(field, navigation.IsOnDependent);
navigation.Builder.HasField(field);
}
}

Expand Down
Loading