/// <summary>
        ///     Returns a value indicating whether the given column for a particular table-like store object can be set for the property.
        /// </summary>
        /// <param name="propertyBuilder"> The builder for the property being configured. </param>
        /// <param name="name"> The name of the column. </param>
        /// <param name="storeObject"> The identifier of the store object. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the property can be mapped to the given column. </returns>
        public static bool CanSetColumnName(
            [NotNull] this IConventionPropertyBuilder propertyBuilder,
            [CanBeNull] string name,
            StoreObjectIdentifier storeObject,
            bool fromDataAnnotation = false)
        {
            var overrides = RelationalPropertyOverrides.Find(propertyBuilder.Metadata, storeObject);

            return(overrides == null ||
                   (fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention)
                   .Overrides(overrides.GetColumnNameConfigurationSource()) ||
                   overrides.ColumnName == name);
        }
Example #2
0
        /// <summary>
        ///     Returns a value indicating whether the given column in a particular view can be set for the property.
        /// </summary>
        /// <param name="propertyBuilder"> The builder for the property being configured. </param>
        /// <param name="name"> The name of the column. </param>
        /// <param name="viewName"> The view name. </param>
        /// <param name="schema"> The view schema. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the property can be mapped to the given column. </returns>
        public static bool CanSetViewColumnName(
            [NotNull] this IConventionPropertyBuilder propertyBuilder,
            [CanBeNull] string name,
            [NotNull] string viewName,
            [CanBeNull] string schema,
            bool fromDataAnnotation = false)
        {
            var overrides = RelationalPropertyOverrides.Find(propertyBuilder.Metadata, viewName, schema);

            return(overrides == null ||
                   (fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention)
                   .Overrides(overrides.GetViewColumnNameConfigurationSource()) ||
                   overrides.ViewColumnName == name);
        }