Esempio n. 1
0
 /// <summary>
 /// Adds/replaces components that respect database schema changes at runtime.
 /// </summary>
 /// <param name="builder">Options builder.</param>
 /// <param name="addDefaultSchemaRespectingComponents">Indication whether to enable or disable the feature.</param>
 /// <returns>The provided <paramref name="builder"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <c>null</c>.</exception>
 public static DbContextOptionsBuilder AddSchemaRespectingComponents(
     this DbContextOptionsBuilder builder,
     bool addDefaultSchemaRespectingComponents = true)
 {
     builder.AddOrUpdateExtension <RelationalDbContextOptionsExtension>(extension => extension.AddSchemaRespectingComponents = addDefaultSchemaRespectingComponents);
     return(builder);
 }
Esempio n. 2
0
 /// <summary>
 /// Adds support for nested transactions.
 /// </summary>
 /// <param name="builder">Options builder.</param>
 /// <param name="addNestedTransactionsSupport">Indication whether to enable or disable the feature.</param>
 /// <returns>The provided <paramref name="builder"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <c>null</c>.</exception>
 public static DbContextOptionsBuilder AddNestedTransactionSupport(
     this DbContextOptionsBuilder builder,
     bool addNestedTransactionsSupport = true)
 {
     builder.AddOrUpdateExtension <RelationalDbContextOptionsExtension>(extension => extension.AddNestedTransactionsSupport = addNestedTransactionsSupport);
     return(builder);
 }
    /// <summary>
    /// 使用存取器扩展。
    /// </summary>
    /// <param name="builder">给定的 <see cref="DbContextOptionsBuilder"/>。</param>
    /// <param name="serviceType">给定的存取器服务类型。</param>
    /// <param name="optionsAction">给定的存取器选项构建器配置动作(可选)。</param>
    /// <returns>返回 <see cref="DbContextOptionsBuilder"/>。</returns>
    public static DbContextOptionsBuilder UseAccessor(this DbContextOptionsBuilder builder,
                                                      Type serviceType, Action <AccessorDbContextOptionsBuilder>?optionsAction = null)
    {
        builder.AddOrUpdateExtension <AccessorDbContextOptionsExtension>(c => c.WithServiceType(serviceType));

        optionsAction?.Invoke(new AccessorDbContextOptionsBuilder(builder));

        return(builder);
    }
Esempio n. 4
0
 /// <summary>
 /// Enables automatic configuration of <see cref="ValueConverter"/> for Smart Enums and Value Objects.
 /// </summary>
 /// <param name="builder">Options builder.</param>
 /// <param name="useValueObjectConventions">Indication whether to enable or disable the feature.</param>
 /// <param name="validateOnWrite">In case of an <see cref="IValidatableEnum{TKey}"/>, ensures that the item is valid before writing it to database.</param>
 /// <param name="configureEnumsAndKeyedValueObjects">Action for further configuration of the property.</param>
 /// <returns>The provided <paramref name="builder"/>.</returns>
 public static DbContextOptionsBuilder UseValueObjectValueConverter(
     this DbContextOptionsBuilder builder,
     bool useValueObjectConventions = true,
     bool validateOnWrite           = true,
     Action <IConventionProperty>?configureEnumsAndKeyedValueObjects = null)
 {
     builder.AddOrUpdateExtension(extension => extension.UseValueObjectValueConverter(useValueObjectConventions, validateOnWrite, configureEnumsAndKeyedValueObjects));
     return(builder);
 }
Esempio n. 5
0
 public static DbContextOptionsBuilder AddExpressionFragmentTranslatorPluginSupport([NotNull] this DbContextOptionsBuilder builder)
 {
     builder.AddOrUpdateExtension <RelationalDbContextOptionsExtension>(extension => extension.ExpressionFragmentTranslatorPluginSupport = true);
     return(builder);
 }
Esempio n. 6
0
 public static DbContextOptionsBuilder AddExpressionFragmentTranslator([NotNull] this DbContextOptionsBuilder builder, [NotNull] IExpressionFragmentTranslator translator)
 {
     builder.AddOrUpdateExtension <RelationalDbContextOptionsExtension>(extension => extension.AddExpressionFragmentTranslator(translator));
     return(builder);
 }
Esempio n. 7
0
 /// <summary>
 /// Adds an <see cref="IEvaluatableExpressionFilterPlugin"/>.
 /// </summary>
 /// <param name="builder">Options builder.</param>
 /// <typeparam name="T">Type of the plugin.</typeparam>
 /// <returns>The provided <paramref name="builder"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <c>null</c>.</exception>
 public static DbContextOptionsBuilder AddEvaluatableExpressionFilterPlugin <T>(this DbContextOptionsBuilder builder)
     where T : IEvaluatableExpressionFilterPlugin
 {
     builder.AddOrUpdateExtension <RelationalDbContextOptionsExtension>(extension => extension.AddEvaluatableExpressionFilterPlugin <T>());
     return(builder);
 }
Esempio n. 8
0
 /// <summary>
 /// Add an <see cref="IRelationalTypeMappingSourcePlugin"/> to dependency injection.
 /// </summary>
 /// <param name="builder">Options builder.</param>
 /// <typeparam name="TPlugin">Type of the plugin implementing <see cref="IRelationalTypeMappingSourcePlugin"/>.</typeparam>
 /// <returns>Options builder for chaining.</returns>
 public static DbContextOptionsBuilder AddRelationalTypeMappingSourcePlugin <TPlugin>(this DbContextOptionsBuilder builder)
     where TPlugin : IRelationalTypeMappingSourcePlugin
 {
     builder.AddOrUpdateExtension <RelationalDbContextOptionsExtension>(extension => extension.AddRelationalTypeMappingSourcePlugin(typeof(TPlugin)));
     return(builder);
 }