コード例 #1
0
        /// <summary>
        /// Applies the annotation configurations for the model builder to the specified model.
        /// </summary>
        /// <param name="modelBuilder">The <see cref="ODataModelBuilder">model builder</see> whose annotation configurations to apply.</param>
        /// <param name="model">The <see cref="IEdmModel">model</see> to apply the annotation configurations to.</param>
        /// <remarks>This method clears all annotation configurations associated with the <paramref name="modelBuilder">model builder</paramref>
        /// after they have been applied to the model.</remarks>
        public static void ApplyAnnotations(this ODataModelBuilder modelBuilder, IEdmModel model)
        {
            Arg.NotNull(modelBuilder, nameof(modelBuilder));
            Arg.NotNull(model, nameof(model));

            // apply casing annotation so that configurations can interogate this from the model later
            model.SetAnnotationValue(model, new LowerCamelCaseAnnotation(modelBuilder.IsLowerCamelCaseEnabled()));

            AnnotationConfigurationCollection configurations;

            if (annotationConfigurations.TryRemove(modelBuilder, out configurations))
            {
                foreach (var configuration in configurations)
                {
                    configuration.Apply(model);
                }

                configurations.Clear();
            }

            ClearModelBuilderMap(modelBuilder);
        }