/// <summary> /// <para> /// Sets the <see cref="PropertyAccessMode" /> to use for navigations of this entity type. /// </para> /// <para> /// Note that individual navigations can override this access mode. The value set here will /// be used for any navigation for which no override has been specified. /// </para> /// </summary> /// <param name="entityType"> The type for which to set the access mode. </param> /// <param name="propertyAccessMode"> The <see cref="PropertyAccessMode" />, or <c>null</c> to clear the mode set. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> public static void SetNavigationAccessMode( [NotNull] this IConventionTypeBase entityType, PropertyAccessMode?propertyAccessMode, bool fromDataAnnotation = false) => Check.NotNull(entityType, nameof(entityType)).AsTypeBase() .SetNavigationAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
/// <summary> /// <para> /// Sets the <see cref="PropertyAccessMode" /> to use for navigations of this entity type. /// </para> /// <para> /// Note that individual navigations can override this access mode. The value set here will /// be used for any navigation for which no override has been specified. /// </para> /// </summary> /// <param name="entityType"> The entity type for which to set the access mode. </param> /// <param name="propertyAccessMode"> The <see cref="PropertyAccessMode" />, or <c>null</c> to clear the mode set. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> public static void SetNavigationAccessMode( [NotNull] this IConventionTypeBase entityType, PropertyAccessMode?propertyAccessMode, bool fromDataAnnotation = false) { Check.NotNull(entityType, nameof(entityType)); entityType.SetOrRemoveAnnotation(CoreAnnotationNames.NavigationAccessMode, propertyAccessMode, fromDataAnnotation); }
private static ForeignKeyAttribute GetForeignKeyAttribute(IConventionTypeBase entityType, string propertyName) => entityType.GetRuntimeProperties()?.Values .FirstOrDefault( p => string.Equals(p.GetSimpleMemberName(), propertyName, StringComparison.OrdinalIgnoreCase) && Attribute.IsDefined(p, typeof(ForeignKeyAttribute), inherit: true)) ?.GetCustomAttribute <ForeignKeyAttribute>(inherit: true);
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public static IReadOnlyDictionary <string, FieldInfo> GetRuntimeFields(this IConventionTypeBase type) => ((TypeBase)type).GetRuntimeFields();
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public static IReadOnlyDictionary <string, PropertyInfo> GetRuntimeProperties(this IConventionTypeBase type) => ((TypeBase)type).GetRuntimeProperties();
/// <summary> /// Returns the configuration source for <see cref="TypeBaseExtensions.GetNavigationAccessMode" />. /// </summary> /// <param name="entityType"> The entity type to find configuration source for. </param> /// <returns> The configuration source for <see cref="TypeBaseExtensions.GetNavigationAccessMode" />. </returns> public static ConfigurationSource?GetNavigationAccessModeConfigurationSource([NotNull] this IConventionTypeBase entityType) => entityType.FindAnnotation(CoreAnnotationNames.NavigationAccessMode)?.GetConfigurationSource();
/// <summary> /// Indicates whether the given member name is ignored. /// </summary> /// <param name="entityType"> The type to check the ignored member. </param> /// <param name="memberName"> The name of the member that might be ignored. </param> /// <returns> <see langword="true" /> if the given member name is ignored. </returns> public static bool IsIgnored([NotNull] this IConventionTypeBase entityType, [NotNull] string memberName) => entityType.FindIgnoredConfigurationSource(memberName) != null;