public static IServiceCollection AddEntityFrameworkCassandra(this IServiceCollection serviceCollection)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <CassandraOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, CassandraTypeMappingSource>()
                          .TryAdd <LoggingDefinitions, CassandraLoggingDefinitions>()
                          // .TryAdd<IMemberTranslator, CassandraCompositeMemberTranslator>()
                          .TryAdd <IMigrator, CassandraMigrator>()
                          .TryAdd <ISqlGenerationHelper, CassandraSqlGenerationHelper>()
                          .TryAdd <IMigrationsSqlGenerator, CassandraMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, CassandraDatabaseCreator>()
                          .TryAdd <IMigrationCommandExecutor, CassandraMigrationCommandExecutor>()
                          .TryAdd <IModificationCommandBatchFactory, CassandraModificationCommandBatchFactory>()
                          .TryAdd <IDatabaseCreator, CassandraDatabaseCreator>()
                          // .TryAdd<ICompositeMethodCallTranslator, CassandraCompositeMethodCallTranslator>()
                          .TryAdd <IHistoryRepository, CassandraHistoryRepository>()
                          .TryAdd <IBatchExecutor, CassandraBatchExecutor>()
                          // .TryAdd<IRelationalResultOperatorHandler, CassandraResultOperatorHandler>()
                          .TryAdd <IRelationalValueBufferFactoryFactory, CassandraTypedRelationalValueBufferFactory>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <ICassandraRelationalConnection>())
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, CassandraSqlTranslatingExpressionVisitorFactory>()
                          .TryAdd <IQuerySqlGeneratorFactory, CassandraSqlGeneratorFactory>()
                          .TryAdd <IUpdateSqlGenerator, CassandraUpdateSqlGenerator>()
                          .TryAdd <IQueryableMethodTranslatingExpressionVisitorFactory, CassandraQueryableMethodTranslatingExpressionVisitorFactory>()
                          .TryAddProviderSpecificServices(b => b.TryAddScoped <ICassandraRelationalConnection, CassandraRelationalConnection>())
                          .TryAddProviderSpecificServices(b => b.TryAddTransient <ICassandraHistoryRepository, CassandraHistoryRepository>());

            builder.TryAddCoreServices();
            return(serviceCollection);
        }
Пример #2
0
        /// <summary>
        ///     <para>
        ///         Adds the services required by the SQLite database provider for Entity Framework
        ///         to an <see cref="IServiceCollection" />. You use this method when using dependency injection
        ///         in your application, such as with ASP.NET. For more information on setting up dependency
        ///         injection, see http://go.microsoft.com/fwlink/?LinkId=526890.
        ///     </para>
        ///     <para>
        ///         You only need to use this functionality when you want Entity Framework to resolve the services it uses
        ///         from an external dependency injection container. If you are not using an external
        ///         dependency injection container, Entity Framework will take care of creating the services it requires.
        ///     </para>
        /// </summary>
        /// <example>
        ///     <code>
        ///          public void ConfigureServices(IServiceCollection services)
        ///          {
        ///              var connectionString = "connection string to database";
        ///
        ///              services
        ///                  .AddEntityFrameworkSqlite()
        ///                  .AddDbContext&lt;MyContext&gt;((serviceProvider, options) =>
        ///                      options.UseSqlite(connectionString)
        ///                             .UseInternalServiceProvider(serviceProvider));
        ///          }
        ///      </code>
        /// </example>
        /// <param name="serviceCollection"> The <see cref="IServiceCollection" /> to add services to. </param>
        /// <returns>
        ///     The same service collection so that multiple calls can be chained.
        /// </returns>
        public static IServiceCollection AddEntityFrameworkSqlite([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <SqliteOptionsExtension> >()
                          .TryAdd <IRelationalTypeMapper, SqliteTypeMapper>()
                          .TryAdd <ISqlGenerationHelper, SqliteSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, SqliteMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, SqliteModelValidator>()
                          .TryAdd <IConventionSetBuilder, SqliteConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator, SqliteUpdateSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, SqliteModificationCommandBatchFactory>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <ISqliteRelationalConnection>())
                          .TryAdd <IMigrationsSqlGenerator, SqliteMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, SqliteDatabaseCreator>()
                          .TryAdd <IHistoryRepository, SqliteHistoryRepository>()
                          .TryAdd <IMemberTranslator, SqliteCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, SqliteCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, SqliteQuerySqlGeneratorFactory>()
                          .TryAddProviderSpecificServices(
                b => b.TryAddScoped <ISqliteRelationalConnection, SqliteRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        public static IServiceCollection AddEntityFrameworkOracle([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <OracleOptionsExtension> >()
                          .TryAdd <IRelationalTypeMapper, OracleSmartTypeMapper>()
                          .TryAdd <ISqlGenerationHelper, OracleSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, OracleMigrationsAnnotationProvider>()
                          .TryAdd <IConventionSetBuilder, OracleConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(p => p.GetService <IOracleUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, OracleModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, OracleValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IOracleRelationalConnection>())
                          .TryAdd <IRelationalCommandBuilderFactory, OracleCommandBuilderFactory>()
                          .TryAdd <IMigrationsSqlGenerator, OracleMigrationsSqlGenerator>()
                          .TryAdd <IBatchExecutor, OracleBatchExecutor>()
                          .TryAdd <IRelationalDatabaseCreator, OracleDatabaseCreator>()
                          .TryAdd <IHistoryRepository, OracleHistoryRepository>()
                          .TryAdd <IExecutionStrategyFactory, OracleExecutionStrategyFactory>()
                          .TryAdd <IMemberTranslator, OracleCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, OracleCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, OracleQuerySqlGeneratorFactory>()
                          .TryAdd <ISingletonOptions, IOracleOptions>(p => p.GetService <IOracleOptions>())
                          .TryAddProviderSpecificServices(b => b
                                                          .TryAddSingleton <IOracleOptions, OracleOptions>()
                                                          .TryAddScoped <IOracleUpdateSqlGenerator, OracleUpdateSqlGenerator>()
                                                          .TryAddScoped <IOracleRelationalConnection, OracleRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
Пример #4
0
        /// <summary>
        /// Adds the services required by the MySQL server database provider for Entity Framework
        /// to an <see cref="IServiceCollection"/>.
        /// </summary>
        /// <example>
        ///     <code>
        ///           public void ConfigureServices(IServiceCollection services)
        ///           {
        ///               var connectionString = "MySQL connection string to database";
        ///
        ///               services
        ///                   .AddEntityFrameworkMySQL()
        ///                   .AddDbContext&lt;MyContext&gt;((serviceProvider, options) =>
        ///                       options.UseMySQL(connectionString)
        ///                              .UseInternalServiceProvider(serviceProvider));
        ///           }
        ///       </code>
        /// </example>
        /// <param name="services">The <see cref="IServiceCollection"/> to add services to.</param>
        /// <returns>The same service collection to enable a chain of multiple calls.</returns>
        public static IServiceCollection AddEntityFrameworkMySQL([NotNull] this IServiceCollection services)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(services)
                          .TryAdd <IRelationalCommandBuilderFactory, MySQLCommandBuilderFactory>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <MySQLOptionsExtension> >()
                          .TryAdd <IValueGeneratorCache, MySQLValueGeneratorCache>()
                          .TryAdd <IRelationalTypeMapper, MySQLTypeMapper>()
                          .TryAdd <ISqlGenerationHelper, MySQLSqlGenerationHelper>()
                          .TryAdd <IModelSource, MySQLModelSource>()
                          .TryAdd <IMigrationsAnnotationProvider, MySQLMigrationsAnnotationProvider>()
                          .TryAdd <IUpdateSqlGenerator, MySQLUpdateSqlGenerator>()
                          .TryAdd <IConventionSetBuilder, MySQLConventionSetBuilder>()
                          .TryAdd <IModificationCommandBatchFactory, MySQLModificationCommandBatchFactory>()
                          .TryAdd <IRelationalConnection, MySQLServerConnection>()
                          .TryAdd <IMigrationsSqlGenerator, MySQLMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, MySQLDatabaseCreator>()
                          .TryAdd <IHistoryRepository, MySQLHistoryRepository>()
                          .TryAdd <IQueryCompilationContextFactory, MySQLQueryCompilationContextFactory>()
                          .TryAdd <IMemberTranslator, MySQLCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, MySQLCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, MySQLQueryGeneratorFactory>();

            builder.TryAddCoreServices();

            return(services);
        }
        public static IServiceCollection AddEntityFrameworkClickHouse([NotNull] this IServiceCollection serviceCollection)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, ClickHouseLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <ClickHouseOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, ClickHouseTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, ClickHouseSqlGenerationHelper>()
                          .TryAdd <IRelationalAnnotationProvider, ClickHouseAnnotationProvider>()
                          .TryAdd <IMigrationsAnnotationProvider, ClickHouseMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, ClickHouseModelValidator>()
                          .TryAdd <IProviderConventionSetBuilder, ClickHouseConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator, ClickHouseUpdateSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, ClickHouseModificationCommandBatchFactory>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IClickHouseRelationalConnection>())
                          .TryAdd <IMigrationsSqlGenerator, ClickHouseMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, ClickHouseDatabaseCreator>()
                          .TryAdd <IHistoryRepository, ClickHouseHistoryRepository>()
                          .TryAdd <IQueryCompiler, ClickHouseQueryCompiler>()
                          //.TryAdd<IRelationalQueryStringFactory, ClickHouseQueryStringFactory>()

                          // New Query Pipeline
                          .TryAdd <IMethodCallTranslatorProvider, ClickHouseMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, ClickHouseMemberTranslatorProvider>()
                          .TryAdd <IQuerySqlGeneratorFactory, ClickHouseQuerySqlGeneratorFactory>()
                          .TryAdd <IQueryableMethodTranslatingExpressionVisitorFactory, ClickHouseQueryableMethodTranslatingExpressionVisitorFactory>()
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, ClickHouseSqlTranslatingExpressionVisitorFactory>()
                          .TryAdd <IValueConverterSelector, ClickHouseValueConverterSelector>()
                          .TryAddProviderSpecificServices(
                b => b.TryAddScoped <IClickHouseRelationalConnection, ClickHouseRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        /// <summary>
        /// Adds base EFCore services along with Cloud Spanner specific services.
        /// </summary>
        public static IServiceCollection AddEntityFrameworkSpanner(this IServiceCollection serviceCollection)
        {
            GaxPreconditions.CheckNotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabase, RelationalDatabase>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <SpannerOptionsExtension> >()
                          .TryAdd <IRelationalTypeMapper, SpannerTypeMapper>()
                          .TryAdd <ISqlGenerationHelper, SpannerSqlGenerationHelper>()
                          //MODEL/MIGRATION SERVICES
                          .TryAdd <IMigrationsAnnotationProvider, SpannerMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, RelationalModelValidator>()
                          .TryAdd <IMigrationsSqlGenerator, SpannerMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, SpannerDatabaseCreator>()
                          .TryAdd <IConventionSetBuilder, SpannerConventionSetBuilder>()
                          //.TryAdd<IHistoryRepository, SpannerHistoryRepository>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <ISpannerRelationalConnection>())
                          .TryAdd <IExecutionStrategyFactory, RelationalExecutionStrategyFactory>()
                          //QUERY SERVICES
                          .TryAdd <IQueryCompilationContextFactory, SpannerQueryCompilationContextFactory>()
                          .TryAdd <IMemberTranslator, SpannerCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, SpannerCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, SpannerQuerySqlGeneratorFactory>()
                          .TryAdd <IRelationalCommandBuilderFactory, SpannerRelationalCommandBuilderFactory>()
                          //UPDATE
                          .TryAdd <IModificationCommandBatchFactory, SpannerModificationCommandBatchFactory>()
                          .TryAddProviderSpecificServices(b => b
                                                          .TryAddScoped <ISpannerRelationalConnection, SpannerRelationalConnection>());

            builder.TryAddCoreServices();
            return(serviceCollection);
        }
        public static IServiceCollection AddEntityFrameworkMySql([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <MySqlOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, MySqlTypeMappingSource>()
                          .TryAdd <IRelationalTransactionFactory, MySqlRelationalTransactionFactory>()
                          .TryAdd <ISqlGenerationHelper, MySqlSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, MySqlMigrationsAnnotationProvider>()
                          .TryAdd <IConventionSetBuilder, MySqlConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(p => p.GetService <IMySqlUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, MySqlModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, MySqlValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IMySqlRelationalConnection>())
                          .TryAdd <IMigrationsSqlGenerator, MySqlMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, MySqlDatabaseCreator>()
                          .TryAdd <IHistoryRepository, MySqlHistoryRepository>()
                          .TryAdd <IExecutionStrategyFactory, MySqlExecutionStrategyFactory>()
                          .TryAdd <IMemberTranslator, MySqlCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, MySqlCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, MySqlQuerySqlGeneratorFactory>()
                          .TryAdd <ISingletonOptions, IMySqlOptions>(p => p.GetService <IMySqlOptions>())
                          .TryAddProviderSpecificServices(b => b
                                                          .TryAddSingleton <IMySqlOptions, MySqlOptions>()
                                                          .TryAddScoped <IMySqlUpdateSqlGenerator, MySqlUpdateSqlGenerator>()
                                                          .TryAddScoped <IMySqlRelationalConnection, MySqlRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
Пример #8
0
        /// <summary>
        ///     <para>
        ///         Adds the services required by the Taos database provider for Entity Framework
        ///         to an <see cref="IServiceCollection" />.
        ///     </para>
        ///     <para>
        ///         Calling this method is no longer necessary when building most applications, including those that
        ///         use dependency injection in ASP.NET or elsewhere.
        ///         It is only needed when building the internal service provider for use with
        ///         the <see cref="DbContextOptionsBuilder.UseInternalServiceProvider" /> method.
        ///         This is not recommend other than for some advanced scenarios.
        ///     </para>
        /// </summary>
        /// <param name="serviceCollection"> The <see cref="IServiceCollection" /> to add services to. </param>
        /// <returns>
        ///     The same service collection so that multiple calls can be chained.
        /// </returns>
        public static IServiceCollection AddEntityFrameworkTaos([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, TaosLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <TaosOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, TaosTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, TaosSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, TaosMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, TaosModelValidator>()
                          .TryAdd <IProviderConventionSetBuilder, TaosConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator, TaosUpdateSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, TaosModificationCommandBatchFactory>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <ITaosRelationalConnection>())
                          .TryAdd <IMigrationsSqlGenerator, TaosMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, TaosDatabaseCreator>()
                          .TryAdd <IHistoryRepository, TaosHistoryRepository>()

                          // New Query Pipeline
                          .TryAdd <IMethodCallTranslatorProvider, TaosMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, TaosMemberTranslatorProvider>()
                          .TryAdd <IQuerySqlGeneratorFactory, TaosQuerySqlGeneratorFactory>()
                          .TryAdd <IQueryableMethodTranslatingExpressionVisitorFactory, TaosQueryableMethodTranslatingExpressionVisitorFactory>()
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, TaosSqlTranslatingExpressionVisitorFactory>()
                          .TryAddProviderSpecificServices(
                b => b.TryAddScoped <ITaosRelationalConnection, TaosRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
Пример #9
0
        public static IServiceCollection AddEntityFrameworkSqlite(this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, SqliteLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <SqliteOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, SqliteTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, SqliteSqlGenerationHelper>()
                          .TryAdd <IRelationalAnnotationProvider, SqliteAnnotationProvider>()
                          .TryAdd <IModelValidator, SqliteModelValidator>()
                          .TryAdd <IProviderConventionSetBuilder, SqliteConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator, SqliteUpdateSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, SqliteModificationCommandBatchFactory>()
                          .TryAdd <IRelationalConnection>(p => p.GetRequiredService <ISqliteRelationalConnection>())
                          .TryAdd <IMigrationsSqlGenerator, SqliteMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, SqliteDatabaseCreator>()
                          .TryAdd <IHistoryRepository, SqliteHistoryRepository>()
                          .TryAdd <IRelationalQueryStringFactory, SqliteQueryStringFactory>()

                          // New Query Pipeline
                          .TryAdd <IMethodCallTranslatorProvider, SqliteMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, SqliteMemberTranslatorProvider>()
                          .TryAdd <IQuerySqlGeneratorFactory, SqliteQuerySqlGeneratorFactory>()
                          .TryAdd <IQueryableMethodTranslatingExpressionVisitorFactory, SqliteQueryableMethodTranslatingExpressionVisitorFactory>()
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, SqliteSqlTranslatingExpressionVisitorFactory>()
                          .TryAdd <IQueryTranslationPostprocessorFactory, SqliteQueryTranslationPostprocessorFactory>()
                          .TryAddProviderSpecificServices(
                b => b.TryAddScoped <ISqliteRelationalConnection, SqliteRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        public static IServiceCollection AddEntityFrameworkOpenEdge(this IServiceCollection serviceCollection)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <OpenEdgeOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, OpenEdgeTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, OpenEdgeSqlGenerationHelper>()
                          .TryAdd <IConventionSetBuilder, OpenEdgeRelationalConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator, OpenEdgeUpdateSqlGenerator>()
                          .TryAdd <ISingletonUpdateSqlGenerator, OpenEdgeUpdateSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, OpenEdgeModificationCommandBatchFactory>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IOpenEdgeRelationalConnection>())
                          .TryAdd <IRelationalResultOperatorHandler, OpenEdgeResultOperatorHandler>()
                          .TryAdd <IQueryModelGenerator, OpenEdgeQueryModelGenerator>()

                          .TryAdd <IBatchExecutor, BatchExecutor>()

                          .TryAdd <IMemberTranslator, OpenEdgeCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, OpenEdgeCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, OpenEdgeSqlGeneratorFactory>()

                          .TryAddProviderSpecificServices(b => b
                                                          .TryAddScoped <IOpenEdgeUpdateSqlGenerator, OpenEdgeUpdateSqlGenerator>()
                                                          .TryAddScoped <IOpenEdgeRelationalConnection, OpenEdgeRelationalConnection>());;

            builder.TryAddCoreServices();
            return(serviceCollection);
        }
Пример #11
0
        /// <summary>
        /// Adds base EFCore services along with Cloud Spanner specific services.
        /// </summary>
        public static IServiceCollection AddEntityFrameworkSpanner(this IServiceCollection serviceCollection)
        {
            GaxPreconditions.CheckNotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, SpannerLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <SpannerOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, SpannerTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, SpannerSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, SpannerMigrationsAnnotationProvider>()
                          .TryAdd <IProviderConventionSetBuilder, SpannerConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator, SpannerUpdateSqlGenerator>()
                          .TryAdd <IBatchExecutor, SpannerBatchExecutor>()
                          .TryAdd <IModificationCommandBatchFactory, SpannerModificationCommandBatchFactory>()
                          .TryAdd <IQuerySqlGeneratorFactory, SpannerQuerySqlGeneratorFactory>()
                          .TryAdd <IMethodCallTranslatorProvider, SpannerMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, SpannerMemberTranslatorProvider>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <ISpannerRelationalConnection>())
                          .TryAdd <IModelValidator, SpannerModelValidator>()
                          .TryAddProviderSpecificServices(p => p.TryAddSingleton(_ => SpannerModelValidationConnectionProvider.Instance))
                          .TryAdd <IMigrationsSqlGenerator, SpannerMigrationsSqlGenerator>()
                          .TryAdd <IMigrationCommandExecutor, SpannerMigrationCommandExecutor>()
                          .TryAdd <IRelationalDatabaseCreator, SpannerDatabaseCreator>()
                          .TryAdd <IHistoryRepository, SpannerHistoryRepository>()
                          .TryAdd <IExecutionStrategyFactory, RelationalExecutionStrategyFactory>()
                          .TryAddProviderSpecificServices(b => b
                                                          .TryAddScoped <ISpannerRelationalConnection, SpannerRelationalConnection>()
                                                          );

            builder.TryAddCoreServices();
            return(serviceCollection);
        }
        public static IServiceCollection AddEntityFrameworkFirebird(this IServiceCollection serviceCollection)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <FbOptionsExtension> >()
                          .TryAdd <IRelationalDatabaseCreator, FbDatabaseCreator>()
                          .TryAdd <IRelationalTypeMapper, FbTypeMapper>()
                          .TryAdd <ISqlGenerationHelper, FbSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, FbMigrationsAnnotationProvider>()
                          .TryAdd <IConventionSetBuilder, FbConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(p => p.GetService <IFbUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, FbModificationCommandBatchFactory>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IFbConnection>())
                          .TryAdd <IMigrationsSqlGenerator, FbMigrationsSqlGenerator>()
                          .TryAdd <IHistoryRepository, FbHistoryRepository>()
                          .TryAdd <IMemberTranslator, FbCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, FbCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, FbQuerySqlGeneratorFactory>()
                          .TryAdd <ISingletonOptions, IFbOptions>(p => p.GetService <IFbOptions>())
                          .TryAddProviderSpecificServices(b => b
                                                          .TryAddSingleton <IFbOptions, FbOptions>()
                                                          .TryAddScoped <IFbUpdateSqlGenerator, FbUpdateSqlGenerator>()
                                                          .TryAddScoped <IFbMigrationSqlGeneratorBehavior, FbMigrationSqlGeneratorBehavior>()
                                                          .TryAddScoped <IFbConnection, FbConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        /// <summary>
        ///     <para>
        ///         Adds the services required by the SQL Server Compact database provider for Entity Framework
        ///         to an <see cref="IServiceCollection" />. You use this method when using dependency injection
        ///         in your application, such as with ASP.NET. For more information on setting up dependency
        ///         injection, see http://go.microsoft.com/fwlink/?LinkId=526890.
        ///     </para>
        ///     <para>
        ///         You only need to use this functionality when you want Entity Framework to resolve the services it uses
        ///         from an external dependency injection container. If you are not using an external
        ///         dependency injection container, Entity Framework will take care of creating the services it requires.
        ///     </para>
        /// </summary>
        /// <example>
        ///     <code>
        ///         public void ConfigureServices(IServiceCollection services)
        ///         {
        ///             var connectionString = "connection string to database";
        ///
        ///             services
        ///                 .AddEntityFrameworkSqlServer()
        ///                 .AddDbContext&lt;MyContext&gt;((serviceProvider, options) =>
        ///                     options.UseSqlServer(connectionString)
        ///                            .UseInternalServiceProvider(serviceProvider));
        ///         }
        ///     </code>
        /// </example>
        /// <param name="serviceCollection"> The <see cref="IServiceCollection" /> to add services to. </param>
        /// <returns>
        ///     The same service collection so that multiple calls can be chained.
        /// </returns>
        public static IServiceCollection AddEntityFrameworkSqlCe([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <SqlCeOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, SqlCeTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, SqlCeSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, SqlCeMigrationsAnnotationProvider>()
                          //.TryAdd<IRelationalValueBufferFactoryFactory, UntypedRelationalValueBufferFactoryFactory>()
                          .TryAdd <IModelValidator, SqlCeModelValidator>()
                          .TryAdd <IConventionSetBuilder, SqlCeConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(p => p.GetService <ISqlCeUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, SqlCeModificationCommandBatchFactory>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <ISqlCeDatabaseConnection>())
                          .TryAdd <IMigrationsSqlGenerator, SqlCeMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, SqlCeDatabaseCreator>()
                          .TryAdd <IHistoryRepository, SqlCeHistoryRepository>()
                          .TryAdd <IQueryCompilationContextFactory, SqlCeQueryCompilationContextFactory>()
                          .TryAdd <IMemberTranslator, SqlCeCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, SqlCeCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, SqlCeQuerySqlGeneratorFactory>()
                          .TryAdd <ISqlTranslatingExpressionVisitorFactory, SqlCeTranslatingExpressionVisitorFactory>()
                          .TryAdd <ISingletonOptions, ISqlCeOptions>(p => p.GetService <ISqlCeOptions>())
                          .TryAddProviderSpecificServices(b => b
                                                          .TryAddSingleton <ISqlCeOptions, SqlCeOptions>()
                                                          .TryAddScoped <ISqlCeUpdateSqlGenerator, SqlCeUpdateSqlGenerator>()
                                                          .TryAddScoped <ISqlCeDatabaseConnection, SqlCeDatabaseConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
Пример #14
0
    public static IServiceCollection AddEntityFrameworkRelationalDatabase(IServiceCollection serviceCollection)
    {
        var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection);

        // Specific test services are available upstream if we need them
        builder.TryAddCoreServices();

        return(serviceCollection);
    }
        public static void AddEntityFrameworkZcoinPostgresPlugins(this IServiceCollection services)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(services);

            builder.TryAddProviderSpecificServices(m =>
            {
                m.TryAddSingletonEnumerable <IRelationalTypeMappingSourcePlugin, TypeMappingSourcePlugin>();
            });
        }
Пример #16
0
        public static IServiceCollection AddEntityFrameworkMySql([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, MySqlLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <MySqlOptionsExtension> >()
                          //.TryAdd<IValueGeneratorCache>(p => p.GetService<IMySqlValueGeneratorCache>())
                          .TryAdd <IRelationalTypeMappingSource, MySqlTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, MySqlSqlGenerationHelper>()
                          .TryAdd <IRelationalAnnotationProvider, MySqlAnnotationProvider>()
                          .TryAdd <IModelValidator, MySqlModelValidator>()
                          .TryAdd <IProviderConventionSetBuilder, MySqlConventionSetBuilder>()
                          //.TryAdd<IRelationalValueBufferFactoryFactory, TypedRelationalValueBufferFactoryFactory>() // What is that?
                          .TryAdd <IUpdateSqlGenerator, MySqlUpdateSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, MySqlModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, MySqlValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IMySqlRelationalConnection>())
                          .TryAdd <IMigrationsSqlGenerator, MySqlMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, MySqlDatabaseCreator>()
                          .TryAdd <IHistoryRepository, MySqlHistoryRepository>()
                          .TryAdd <ICompiledQueryCacheKeyGenerator, MySqlCompiledQueryCacheKeyGenerator>()
                          .TryAdd <IExecutionStrategyFactory, MySqlExecutionStrategyFactory>()
                          .TryAdd <IRelationalQueryStringFactory, MySqlQueryStringFactory>()
                          .TryAdd <IMigrator, MySqlMigrator>()
                          .TryAdd <IMethodCallTranslatorProvider, MySqlMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, MySqlMemberTranslatorProvider>()
                          .TryAdd <IEvaluatableExpressionFilter, MySqlEvaluatableExpressionFilter>()
                          .TryAdd <IQuerySqlGeneratorFactory, MySqlQuerySqlGeneratorFactory>()
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, MySqlSqlTranslatingExpressionVisitorFactory>()
                          .TryAdd <IRelationalParameterBasedSqlProcessorFactory, MySqlParameterBasedSqlProcessorFactory>()
                          .TryAdd <ISqlExpressionFactory, MySqlSqlExpressionFactory>()
                          .TryAdd <ISingletonOptions, IMySqlOptions>(p => p.GetService <IMySqlOptions>())
                          //.TryAdd<IValueConverterSelector, MySqlValueConverterSelector>()
                          .TryAdd <IQueryCompilationContextFactory, MySqlQueryCompilationContextFactory>()
                          .TryAdd <IQueryTranslationPostprocessorFactory, MySqlQueryTranslationPostprocessorFactory>()
                          .TryAdd <IMigrationsModelDiffer, MySqlMigrationsModelDiffer>()
                          .TryAdd <IRelationalTransactionFactory, MySqlRelationalTransactionFactory>() // CHECK: Still needed?
                          .TryAddProviderSpecificServices(m => m
                                                                                                       //.TryAddSingleton<IMySqlValueGeneratorCache, MySqlValueGeneratorCache>()
                                                          .TryAddSingleton <IMySqlOptions, MySqlOptions>()
                                                                                                       //.TryAddScoped<IMySqlSequenceValueGeneratorFactory, MySqlSequenceValueGeneratorFactory>()
                                                          .TryAddScoped <IMySqlUpdateSqlGenerator, MySqlUpdateSqlGenerator>()
                                                          .TryAddScoped <IMySqlRelationalConnection, MySqlRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        /// <summary>
        ///     <para>
        ///         Adds the services required by the Microsoft SQL Server database provider for Entity Framework
        ///         to an <see cref="IServiceCollection" />. You use this method when using dependency injection
        ///         in your application, such as with ASP.NET. For more information on setting up dependency
        ///         injection, see http://go.microsoft.com/fwlink/?LinkId=526890.
        ///     </para>
        ///     <para>
        ///         You only need to use this functionality when you want Entity Framework to resolve the services it uses
        ///         from an external dependency injection container. If you are not using an external
        ///         dependency injection container, Entity Framework will take care of creating the services it requires.
        ///     </para>
        /// </summary>
        /// <example>
        ///     <code>
        ///            public void ConfigureServices(IServiceCollection services)
        ///            {
        ///                var connectionString = "connection string to database";
        ///
        ///                services
        ///                    .AddEntityFrameworkSqlServer()
        ///                    .AddDbContext&lt;MyContext&gt;((serviceProvider, options) =>
        ///                        options.UseSqlServer(connectionString)
        ///                               .UseInternalServiceProvider(serviceProvider));
        ///            }
        ///        </code>
        /// </example>
        /// <param name="serviceCollection"> The <see cref="IServiceCollection" /> to add services to. </param>
        /// <returns>
        ///     The same service collection so that multiple calls can be chained.
        /// </returns>
        public static IServiceCollection AddEntityFrameworkSqlServer([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, SqlServerLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <SqlServerOptionsExtension> >()
                          .TryAdd <IValueGeneratorCache>(p => p.GetService <ISqlServerValueGeneratorCache>())
                          .TryAdd <IRelationalTypeMappingSource, SqlServerTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, SqlServerSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, SqlServerMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, SqlServerModelValidator>()
                          .TryAdd <IProviderConventionSetBuilder, SqlServerConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(p => p.GetService <ISqlServerUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, SqlServerModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, SqlServerValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <ISqlServerConnection>())
                          .TryAdd <IMigrationsSqlGenerator, SqlServerMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, SqlServerDatabaseCreator>()
                          .TryAdd <IHistoryRepository, SqlServerHistoryRepository>()
                          .TryAdd <ICompiledQueryCacheKeyGenerator, SqlServerCompiledQueryCacheKeyGenerator>()
                          .TryAdd <IExecutionStrategyFactory, SqlServerExecutionStrategyFactory>()
                          .TryAdd <IQueryCompilationContextFactory, SqlServerQueryCompilationContextFactory>()
                          .TryAdd <IQuerySqlGeneratorFactory, SqlServerQuerySqlGeneratorFactory>()
                          .TryAdd <ISingletonOptions, ISqlServerOptions>(p => p.GetService <ISqlServerOptions>())

                          // New Query Pipeline
                          .TryAdd <IMethodCallTranslatorProvider, SqlServerMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, SqlServerMemberTranslatorProvider>()
                          .TryAdd <IShapedQueryOptimizerFactory, SqlServerShapedQueryOptimizerFactory>()
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, SqlServerSqlTranslatingExpressionVisitorFactory>()


                          .TryAddProviderSpecificServices(
                b => b
                .TryAddSingleton <ISqlServerValueGeneratorCache, SqlServerValueGeneratorCache>()
                .TryAddSingleton <ISqlServerOptions, SqlServerOptions>()
                .TryAddSingleton <ISqlServerUpdateSqlGenerator, SqlServerUpdateSqlGenerator>()
                .TryAddSingleton <ISqlServerSequenceValueGeneratorFactory, SqlServerSequenceValueGeneratorFactory>()
                .TryAddScoped <ISqlServerConnection, SqlServerConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        /// <summary>
        ///  添加Oracle实体框架
        /// </summary>
        /// <param name="serviceCollection">服务集合</param>
        /// <returns></returns>
        public static IServiceCollection AddEntityFrameworkOracle([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            // 注册服务。仅当实体框架服务的实现尚未注册时添加。服务的范围由实体框架自己定义。
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <OracleOptionsExtension> >()
                          .TryAdd <IValueGeneratorCache>(p => p.GetService <IOracleValueGeneratorCache>())
                          .TryAdd <IRelationalTypeMappingSource, OracleTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, OracleSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, OracleMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, OracleModelValidator>()
                          .TryAdd <IConventionSetBuilder, OracleConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator, OracleUpdateSqlGenerator>()
                          .TryAdd <ISingletonUpdateSqlGenerator, OracleUpdateSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, OracleModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, OracleValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IOracleConnection>())
                          .TryAdd <IMigrationsSqlGenerator, OracleMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, OracleDatabaseCreator>()
                          .TryAdd <IHistoryRepository, OracleHistoryRepository>()
                          .TryAdd <ICompiledQueryCacheKeyGenerator, OracleCompiledQueryCacheKeyGenerator>()
                          .TryAdd <IExecutionStrategyFactory, OracleExecutionStrategyFactory>()
                          .TryAdd <IQueryCompilationContextFactory, OracleQueryCompilationContextFactory>()
                          .TryAdd <IMemberTranslator, OracleCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, OracleCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, OracleQuerySqlGeneratorFactory>()
                          .TryAdd <IRelationalCommandBuilderFactory, OracleRelationalCommandBuilderFactory>()
                          .TryAdd <IMigrationCommandExecutor, OracleMigrationCommandExecutor>()
                          .TryAdd <ISingletonOptions, IOracleOptions>((IServiceProvider p) => p.GetService <IOracleOptions>())
                          .TryAddProviderSpecificServices(delegate(ServiceCollectionMap b)
            {
                b.TryAddSingleton <IOracleValueGeneratorCache, OracleValueGeneratorCache>()
                .TryAddSingleton <IOracleOptions, OracleOptions>()
                .TryAddScoped <IOracleSequenceValueGeneratorFactory, OracleSequenceValueGeneratorFactory>()
                .TryAddScoped <IOracleConnection, OracleRelationalConnection>();
            });

            // 尝试将服务注册到内核。数据库提供程序必须在服务注册的最后一步调用此方法,即在所有提供程序服务注册之后。
            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        public static IServiceCollection AddEntityFrameworkRelationalDatabase(IServiceCollection serviceCollection)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, TestRelationalLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <FakeRelationalOptionsExtension> >()
                          .TryAdd <ISqlGenerationHelper, RelationalSqlGenerationHelper>()
                          .TryAdd <IRelationalTypeMappingSource, TestRelationalTypeMappingSource>()
                          .TryAdd <IMigrationsSqlGenerator, TestRelationalMigrationSqlGenerator>()
                          .TryAdd <IProviderConventionSetBuilder, TestRelationalConventionSetBuilder>()
                          .TryAdd <IRelationalConnection, FakeRelationalConnection>()
                          .TryAdd <IHistoryRepository>(_ => null)
                          .TryAdd <IUpdateSqlGenerator, FakeSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, TestModificationCommandBatchFactory>()
                          .TryAdd <IRelationalDatabaseCreator, FakeRelationalDatabaseCreator>();

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        /// <summary>
        ///     <para>
        ///         Adds the services required by the Npgsql database provider for Entity Framework
        ///         to an <see cref="IServiceCollection" />. You use this method when using dependency injection
        ///         in your application, such as with ASP.NET. For more information on setting up dependency
        ///         injection, see http://go.microsoft.com/fwlink/?LinkId=526890.
        ///     </para>
        ///     <para>
        ///         You only need to use this functionality when you want Entity Framework to resolve the services it uses
        ///         from an external <see cref="IServiceCollection" />. If you are not using an external
        ///         <see cref="IServiceCollection" /> Entity Framework will take care of creating the services it requires.
        ///     </para>
        /// </summary>
        /// <example>
        ///     <code>
        ///         public void ConfigureServices(IServiceCollection services)
        ///         {
        ///             var connectionString = "connection string to database";
        ///
        ///             services
        ///                 .AddEntityFrameworkSqlServer()
        ///                 .AddDbContext&lt;MyContext&gt;(options => options.UseNpgsql(connectionString));
        ///         }
        ///     </code>
        /// </example>
        /// <param name="serviceCollection"> The <see cref="IServiceCollection" /> to add services to. </param>
        /// <returns>
        ///     A builder that allows further Entity Framework specific setup of the <see cref="IServiceCollection" />.
        /// </returns>
        public static IServiceCollection AddEntityFrameworkNpgsql([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder =
                new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                .TryAdd <IDatabaseProvider, DatabaseProvider <NpgsqlOptionsExtension> >()
                .TryAdd <IValueGeneratorCache>(p => p.GetService <INpgsqlValueGeneratorCache>())
                .TryAdd <IRelationalTypeMappingSource, NpgsqlTypeMappingSource>()
                .TryAdd <ISqlGenerationHelper, NpgsqlSqlGenerationHelper>()
                .TryAdd <IMigrationsAnnotationProvider, NpgsqlMigrationsAnnotationProvider>()
                .TryAdd <IModelValidator, NpgsqlModelValidator>()
                .TryAdd <IRelationalValueBufferFactoryFactory, TypedRelationalValueBufferFactoryFactory>()
                .TryAdd <IConventionSetBuilder, NpgsqlConventionSetBuilder>()
                .TryAdd <IUpdateSqlGenerator, NpgsqlUpdateSqlGenerator>()
                .TryAdd <IModificationCommandBatchFactory, NpgsqlModificationCommandBatchFactory>()
                .TryAdd <IValueGeneratorSelector, NpgsqlValueGeneratorSelector>()
                .TryAdd <IRelationalConnection>(p => p.GetService <INpgsqlRelationalConnection>())
                .TryAdd <IMigrationsSqlGenerator, NpgsqlMigrationsSqlGenerator>()
                .TryAdd <IRelationalDatabaseCreator, NpgsqlDatabaseCreator>()
                .TryAdd <IHistoryRepository, NpgsqlHistoryRepository>()
                .TryAdd <ICompiledQueryCacheKeyGenerator, NpgsqlCompiledQueryCacheKeyGenerator>()
                .TryAdd <IExecutionStrategyFactory, NpgsqlExecutionStrategyFactory>()
                .TryAdd <IQueryCompilationContextFactory, NpgsqlQueryCompilationContextFactory>()
                .TryAdd <IMemberTranslator, NpgsqlCompositeMemberTranslator>()
                .TryAdd <ICompositeMethodCallTranslator, NpgsqlCompositeMethodCallTranslator>()
                .TryAdd <IExpressionFragmentTranslator, NpgsqlCompositeExpressionFragmentTranslator>()
                .TryAdd <IQuerySqlGeneratorFactory, NpgsqlQuerySqlGeneratorFactory>()
                .TryAdd <ISqlTranslatingExpressionVisitorFactory, NpgsqlSqlTranslatingExpressionVisitorFactory>()
                .TryAdd <ISingletonOptions, INpgsqlOptions>(p => p.GetService <INpgsqlOptions>())
                .TryAdd <IEvaluatableExpressionFilter, NpgsqlCompositeEvaluatableExpressionFilter>()
                .TryAddProviderSpecificServices(
                    b => b
                    .TryAddSingleton <INpgsqlValueGeneratorCache, NpgsqlValueGeneratorCache>()
                    .TryAddSingleton <INpgsqlOptions, NpgsqlOptions>()
                    .TryAddScoped <INpgsqlSequenceValueGeneratorFactory, NpgsqlSequenceValueGeneratorFactory>()
                    .TryAddScoped <INpgsqlRelationalConnection, NpgsqlRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
Пример #21
0
        public static IServiceCollection AddEntityFrameworkVfp([NotNull] this IServiceCollection serviceCollection)
        {
            serviceCollection.ThrowIfNull(nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, VfpLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <VfpOptionsExtension> >()
                          .TryAdd <IValueGeneratorCache>(p => p.GetService <IVfpValueGeneratorCache>())
                          .TryAdd <IRelationalTypeMappingSource, VfpTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, VfpSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, VfpMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, VfpModelValidator>()
                          .TryAdd <IProviderConventionSetBuilder, VfpConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(x => x.GetService <IVfpUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, VfpModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, VfpValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IVfpConnection>())
                          .TryAdd <IMigrationsSqlGenerator, VfpMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, VfpDatabaseCreator>()
                          .TryAdd <IHistoryRepository, VfpHistoryRepository>()
                          .TryAdd <IExecutionStrategyFactory, VfpExecutionStrategyFactory>()
                          .TryAdd <IRelationalQueryStringFactory, VfpQueryStringFactory>()
                          .TryAdd <IQueryTranslationPostprocessorFactory, VfpQueryTranslationPostprocessorFactory>()
                          .TryAdd <ISqlExpressionFactory, VfpSqlExpressionFactory>()
                          // Query
                          .TryAdd <IMethodCallTranslatorProvider, VfpMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, VfpMemberTranslatorProvider>()
                          .TryAdd <IQuerySqlGeneratorFactory, VfpQuerySqlGeneratorFactory>()
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, VfpSqlTranslatingExpressionVisitorFactory>()
                          .TryAdd <IRelationalParameterBasedSqlProcessorFactory, VfpParameterBasedSqlProcessorFactory>()
                          .TryAddProviderSpecificServices(x => x
                                                          .TryAddSingleton <IVfpValueGeneratorCache, VfpValueGeneratorCache>()
                                                          .TryAddSingleton <IVfpUpdateSqlGenerator, VfpUpdateSqlGenerator>()
                                                          .TryAddScoped <IVfpConnection, VfpConnection>()
                                                          );

            ;

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
    public static IServiceCollection AddEntityFrameworkJson(this IServiceCollection serviceCollection)
    {
        var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                      .TryAdd <IDatabaseProvider, DatabaseProvider <JsonOptionsExtension> >()
                      .TryAdd <LoggingDefinitions, JsonLoggingDefinitions>()
                      .TryAdd <IRelationalConnection, JsonRelationalConnection>()
                      .TryAdd <IRelationalTypeMappingSource, JsonTypeMappingSource>()
                      .TryAdd <ISqlGenerationHelper, JsonSqlGenerationHelper>()
                      .TryAdd <IModificationCommandBatchFactory, JsonModificationCommandBatchFactory>()
                      .TryAdd <ISingletonOptions, JsonOptions>()
                      .TryAdd <IModelValidator, JsonModelValidator>()
                      .TryAdd <IProviderConventionSetBuilder, JsonConventionSetBuilder>()
                      .TryAdd <IRelationalDatabaseCreator, JsonDatabaseCreator>()
                      // .TryAdd<IRelationalTransactionFactory, MySqlRelationalTransactionFactory>()
                      // .TryAdd<IMigrationsAnnotationProvider, MySqlMigrationsAnnotationProvider>()
                      // .TryAdd<IProviderConventionSetBuilder, MySqlConventionSetBuilder>()
                      // .TryAdd<IModelValidator, MySqlModelValidator>()
                      // .TryAdd<IUpdateSqlGenerator, MySqlUpdateSqlGenerator>()
                      // .TryAdd<IValueGeneratorSelector, MySqlValueGeneratorSelector>()
                      // .TryAdd<IMigrationsSqlGenerator, MySqlMigrationsSqlGenerator>()
                      //
                      // .TryAdd<IHistoryRepository, MySqlHistoryRepository>()
                      // .TryAdd<ICompiledQueryCacheKeyGenerator, MySqlCompiledQueryCacheKeyGenerator>()
                      // .TryAdd<IExecutionStrategyFactory, MySqlExecutionStrategyFactory>()
                      // .TryAdd<IMigrator, MySqlMigrator>()
                      // .TryAdd<IMethodCallTranslatorProvider, MySqlMethodCallTranslatorProvider>()
                      // .TryAdd<IMemberTranslatorProvider, MySqlMemberTranslatorProvider>()
                      // .TryAdd<IQuerySqlGeneratorFactory, MySqlQuerySqlGeneratorFactory>()
                      // .TryAdd<ISqlExpressionFactory, MySqlSqlExpressionFactory>()
                      // .TryAdd<IRelationalSqlTranslatingExpressionVisitorFactory, MySqlSqlTranslatingExpressionVisitorFactory>()
                      // .TryAdd<IQueryTranslationPostprocessorFactory, MySqlQueryTranslationPostprocessorFactory>()
                      // .TryAdd<IMigrationsModelDiffer, MySqlMigrationsModelDiffer>()
                      // .TryAddProviderSpecificServices(m => m
                      //     .TryAddSingleton<IMySqlOptions, MySqlOptions>()
                      //     .TryAddScoped<IMySqlRelationalConnection, MySqlRelationalConnection>()
                      //     .TryAddScoped<IMySqlUpdateSqlGenerator, MySqlUpdateSqlGenerator>())
        ;

        builder.TryAddCoreServices();

        return(serviceCollection);
    }
        public static IServiceCollection AddEntityFrameworkKoralium(this IServiceCollection serviceCollection)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <LoggingDefinitions, KoraliumLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <KoraliumOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, KoraliumTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, KoraliumSqlGenerationHelper>()
                          .TryAdd <IModificationCommandBatchFactory, KoraliumModificationCommandBatchFactory>()
                          .TryAdd <IUpdateSqlGenerator, KoraliumUpdateSqlGenerator>()
                          .TryAdd <IQuerySqlGeneratorFactory, KoraliumQuerySqlGeneratorFactory>()
                          .TryAdd <IQueryableMethodTranslatingExpressionVisitorFactory, KoraliumQueryableMethodTranslatingExpressionVisitorFactory>()
                          .TryAdd <IRelationalConnection, KoraliumRelationalConnection>()

                          //New query pipeline
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, KoraliumSqlTranslatingExpressionVisitorFactory>();

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        public static IServiceCollection AddEntityFrameworkRelationalDatabase(IServiceCollection serviceCollection)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <FakeRelationalOptionsExtension> >()
                          .TryAdd <ISqlGenerationHelper, RelationalSqlGenerationHelper>()
                          .TryAdd <IRelationalTypeMapper, TestRelationalTypeMapper>()
                          .TryAdd <IMigrationsSqlGenerator, TestRelationalMigrationSqlGenerator>()
                          .TryAdd <IConventionSetBuilder, TestRelationalConventionSetBuilder>()
                          .TryAdd <IMemberTranslator, TestRelationalCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, TestRelationalCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, TestQuerySqlGeneratorFactory>()
                          .TryAdd <IRelationalConnection, FakeRelationalConnection>()
                          .TryAdd <IHistoryRepository>(_ => null)
                          .TryAdd <IUpdateSqlGenerator, FakeSqlGenerator>()
                          .TryAdd <IModificationCommandBatchFactory, TestModificationCommandBatchFactory>()
                          .TryAdd <IRelationalDatabaseCreator, FakeRelationalDatabaseCreator>();

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
        /// <summary>
        ///     <para>
        ///         Adds the services required by the Microsoft Jet database provider for Entity Framework
        ///         to an <see cref="IServiceCollection" />. You use this method when using dependency injection
        ///         in your application, such as with ASP.NET. For more information on setting up dependency
        ///         injection, see http://go.microsoft.com/fwlink/?LinkId=526890.
        ///     </para>
        ///     <para>
        ///         You only need to use this functionality when you want Entity Framework to resolve the services it uses
        ///         from an external dependency injection container. If you are not using an external
        ///         dependency injection container, Entity Framework will take care of creating the services it requires.
        ///     </para>
        /// </summary>
        /// <example>
        ///     <code>
        ///           public void ConfigureServices(IServiceCollection services)
        ///           {
        ///               var connectionString = "connection string to database";
        ///
        ///               services
        ///                   .AddEntityFrameworkJet()
        ///                   .AddDbContext&lt;MyContext&gt;((serviceProvider, options) =>
        ///                       options.UseJet(connectionString)
        ///                              .UseInternalServiceProvider(serviceProvider));
        ///           }
        ///       </code>
        /// </example>
        /// <param name="serviceCollection"> The <see cref="IServiceCollection" /> to add services to. </param>
        /// <returns>
        ///     The same service collection so that multiple calls can be chained.
        /// </returns>
        public static IServiceCollection AddEntityFrameworkJet([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));

            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          .TryAdd <IDatabaseProvider, DatabaseProvider <JetOptionsExtension> >()
                          .TryAdd <IValueGeneratorCache>(p => p.GetService <IJetValueGeneratorCache>())
                          .TryAdd <IRelationalTypeMapper, JetTypeMapper>()

                          .TryAdd <IEntityMaterializerSource, JetEntityMaterializerSource>()

                          .TryAdd <ISqlGenerationHelper, JetSqlGenerationHelper>()
                          .TryAdd <IMigrationsAnnotationProvider, JetMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, JetModelValidator>()
                          .TryAdd <IConventionSetBuilder, JetConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(p => p.GetService <IJetUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, JetModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, JetValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IJetRelationalConnection>())
                          .TryAdd <IMigrationsSqlGenerator, JetMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, JetDatabaseCreator>()
                          .TryAdd <IHistoryRepository, JetHistoryRepository>()
                          .TryAdd <ICompiledQueryCacheKeyGenerator, JetCompiledQueryCacheKeyGenerator>()
                          .TryAdd <IQueryCompilationContextFactory, JetQueryCompilationContextFactory>()
                          .TryAdd <IMemberTranslator, JetCompositeMemberTranslator>()
                          .TryAdd <ICompositeMethodCallTranslator, JetCompositeMethodCallTranslator>()
                          .TryAdd <IQuerySqlGeneratorFactory, JetQuerySqlGeneratorFactory>()
                          .TryAdd <ISingletonOptions, IJetOptions>(p => p.GetService <IJetOptions>())
                          .TryAddProviderSpecificServices(
                b => b
                .TryAddSingleton <IJetValueGeneratorCache, JetValueGeneratorCache>()
                .TryAddSingleton <IJetOptions, JetOptions>()
                .TryAddScoped <IJetUpdateSqlGenerator, JetUpdateSqlGenerator>()
                .TryAddScoped <IJetSequenceValueGeneratorFactory, JetSequenceValueGeneratorFactory>()
                .TryAddScoped <IJetRelationalConnection, JetRelationalConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }
Пример #26
0
        public static IServiceCollection AddEntityFrameworkJson(this IServiceCollection serviceCollection)
        {
            Console.WriteLine(nameof(JsonServiceCollectionExtensions) + '.' + nameof(AddEntityFrameworkJson));
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
                          // 1.
                          .TryAdd <ISingletonOptionsInitializer, SingletonOptionsInitializer>()
                          // 2.
                          .TryAdd <IDbSetInitializer, DbSetInitializer>()
                          // 3.
                          .TryAdd <IDbSetFinder, DbSetFinder>()
                          // 4.
                          .TryAdd <IDbSetSource, DbSetSource>()

                          //.TryAdd<IDatabaseProvider, DatabaseProvider<JsonOptionsExtension>>()
                          //.TryAdd<IRelationalDatabaseCreator, JsonDatabaseCreator>()
                          //.TryAdd<IRelationalTypeMappingSource, JsonTypeMappingSource>()
                          //.TryAdd<ISqlGenerationHelper, JsonSqlGenerationHelper>()
                          //.TryAdd<IMigrationsAnnotationProvider, JsonMigrationsAnnotationProvider>()
                          //.TryAdd<IConventionSetBuilder, JsonConventionSetBuilder>()
                          //.TryAdd<IUpdateSqlGenerator>(p => p.GetService<IJsonUpdateSqlGenerator>())
                          //.TryAdd<IModificationCommandBatchFactory, JsonModificationCommandBatchFactory>()
                          //.TryAdd<IRelationalConnection>(p => p.GetService<IJsonRelationalConnection>())
                          //.TryAdd<IMigrationsSqlGenerator, JsonMigrationsSqlGenerator>()
                          //.TryAdd<IHistoryRepository, JsonHistoryRepository>()
                          //.TryAdd<IQueryCompilationContextFactory, JsonQueryCompilationContextFactory>()
                          //.TryAdd<ICompositeMethodCallTranslator, JsonCompositeMethodCallTranslator>()
                          //.TryAdd<IQuerySqlGeneratorFactory, JsonQuerySqlGeneratorFactory>()
                          //.TryAdd<ISingletonOptions, IJsonOptions>(p => p.GetService<IJsonOptions>())
                          //.TryAddProviderSpecificServices(b =>
                          //{
                          //b
                          //.TryAddSingleton<IJsonOptions, JsonOptions>()
                          //.TryAddSingleton<IJsonMigrationSqlGeneratorBehavior, JsonMigrationSqlGeneratorBehavior>()
                          //.TryAddSingleton<IJsonUpdateSqlGenerator, JsonUpdateSqlGenerator>()
                          //.TryAddScoped<IJsonRelationalConnection, JsonRelationalConnection>()
                          //});
            ;

            return(serviceCollection);
        }
        /// <summary>
        ///     <para>
        ///         Adds the services required by the Microsoft SQL Server database provider for Entity Framework
        ///         to an <see cref="IServiceCollection" />.
        ///     </para>
        ///     <para>
        ///         Calling this method is no longer necessary when building most applications, including those that
        ///         use dependency injection in ASP.NET or elsewhere.
        ///         It is only needed when building the internal service provider for use with
        ///         the <see cref="DbContextOptionsBuilder.UseInternalServiceProvider" /> method.
        ///         This is not recommend other than for some advanced scenarios.
        ///     </para>
        /// </summary>
        /// <param name="serviceCollection"> The <see cref="IServiceCollection" /> to add services to. </param>
        /// <returns>
        ///     The same service collection so that multiple calls can be chained.
        /// </returns>
        public static IServiceCollection AddEntityFrameworkMySQL([NotNull] this IServiceCollection services)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(services)
                          .TryAdd <LoggingDefinitions, MySQLLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <MySQLOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, MySQLTypeMapper>()
                          .TryAdd <ISqlGenerationHelper, MySQLSqlGenerationHelper>()
                          .TryAdd <IRelationalAnnotationProvider, MySQLMigrationsAnnotationProvider>()
                          .TryAdd <IModelValidator, MySQLModelValidator>()
                          .TryAdd <IProviderConventionSetBuilder, MySQLConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(p => p.GetService <IMySQLUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, MySQLModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, MySQLValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IMySQLServerConnection>())
                          .TryAdd <IMigrationsSqlGenerator, MySQLMigrationsSqlGenerator>()
                          .TryAdd <IRelationalDatabaseCreator, MySQLDatabaseCreator>()
                          .TryAdd <IHistoryRepository, MySQLHistoryRepository>()
                          .TryAdd <ICompiledQueryCacheKeyGenerator, MySQLCompiledQueryCacheKeyGenerator>()
                          .TryAdd <IExecutionStrategyFactory, MySQLExecutionStrategyFactory>()

                          .TryAdd <ISingletonOptions, IMySQLOptions>(p => p.GetService <IMySQLOptions>())

                          // New Query Pipeline
                          .TryAdd <IMethodCallTranslatorProvider, MySQLMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, MySQLMemberTranslatorProvider>()
                          .TryAdd <IQuerySqlGeneratorFactory, MySQLQueryGeneratorFactory>()
                          .TryAdd <ISqlExpressionFactory, MySQLSqlExpressionFactory>()
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, MySQLSqlTranslatingExpressionVisitorFactory>()
                          .TryAdd <IQueryTranslationPostprocessorFactory, MySQLQueryTranslationPostprocessorFactory>()
                          .TryAdd <IMigrationsModelDiffer, MySQLMigrationsModelDiffer>()
                          .TryAddProviderSpecificServices(m => m
                                                          .TryAddSingleton <IMySQLOptions, MySQLOptions>()
                                                          .TryAddScoped <IMySQLServerConnection, MySQLServerConnection>()
                                                          .TryAddSingleton <IMySQLUpdateSqlGenerator, MySQLUpdateSqlGenerator>());

            builder.TryAddCoreServices();

            return(services);
        }
        public static IServiceCollection AddEntityFrameworkFileMaker(this IServiceCollection services)
        {
            if (services is null)
            {
                throw new System.ArgumentNullException(nameof(services));
            }

            var builder = new EntityFrameworkRelationalServicesBuilder(services)
                          .TryAdd <LoggingDefinitions, FileMakerLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <FileMakerOptionsExtension> >()
                          .TryAdd <IRelationalTypeMappingSource, FileMakerTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, FileMakerSqlGenerationHelper>()
                          .TryAdd <IModificationCommandBatchFactory, FileMakerModificationCommandBatchFactory>()
                          .TryAdd <IUpdateSqlGenerator, FileMakerUpdateSqlGenerator>()
                          .TryAdd <IProviderConventionSetBuilder, FileMakerConventionSetBuilder>()
                          .TryAdd <IMethodCallTranslatorProvider, FileMakerMethodCallTranslatorProvider>()
                          .TryAdd <IRelationalConnection, FileMakerConnection>()
                          .TryAdd <IQuerySqlGeneratorFactory, FileMakerQuerySqlGeneratorFactory>();

            builder.TryAddCoreServices();

            return(services);
        }
Пример #29
0
        public static IServiceCollection AddEntityFrameworkAS400x([NotNull] this IServiceCollection serviceCollection)
        {
            Check.NotNull(serviceCollection, nameof(serviceCollection));
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection);

            builder.TryAdd <IDatabaseProvider, DatabaseProvider <AS400OptionsExtension> >();
            builder.TryAdd <IValueGeneratorCache>(p => p.GetService <IAS400ValueGeneratorCache>());
            builder.TryAdd <IRelationalTypeMapper, AS400TypeMapper>();
            builder.TryAdd <ISqlGenerationHelper, AS400SqlGenerationHelper>();
            //TODO  builder.TryAdd<IMigrationsAnnotationProvider, AS400MigrationsAnnotationProvider>();
            builder.TryAdd <IRelationalValueBufferFactoryFactory, UntypedRelationalValueBufferFactoryFactory>();
            builder.TryAdd <IModelValidator, AS400ModelValidator>();
            builder.TryAdd <IConventionSetBuilder, AS400ConventionSetBuilder>();
            builder.TryAdd <IUpdateSqlGenerator>(p => p.GetService <IAS400UpdateSqlGenerator>());
            builder.TryAdd <IModificationCommandBatchFactory, AS400ModificationCommandBatchFactory>();
            builder.TryAdd <IValueGeneratorSelector, AS400ValueGeneratorSelector>();
            builder.TryAdd <IRelationalConnection>(p => p.GetService <IAS400RelationalConnection>());
            //TODO  builder.TryAdd<IMigrationsSqlGenerator, AS400MigrationsSqlGenerator>();
            //TODO  builder.TryAdd<IRelationalDatabaseCreator, AS400DatabaseCreator>();
            //TODO  builder.TryAdd<IHistoryRepository, AS400HistoryRepository>();
            builder.TryAdd <ICompiledQueryCacheKeyGenerator, AS400CompiledQueryCacheKeyGenerator>();
            builder.TryAdd <IExecutionStrategyFactory, AS400ExecutionStrategyFactory>();
            builder.TryAdd <IQueryCompilationContextFactory, AS400QueryCompilationContextFactory>();
            builder.TryAdd <IMemberTranslator, AS400CompositeMemberTranslator>();
            builder.TryAdd <ICompositeMethodCallTranslator, AS400CompositeMethodCallTranslator>();
            builder.TryAdd <IQuerySqlGeneratorFactory, AS400QuerySqlGeneratorFactory>();
            builder.TryAdd <ISingletonOptions, IAS400Options>(p => p.GetService <IAS400Options>());
            builder.TryAddProviderSpecificServices(delegate(ServiceCollectionMap b) {
                b.TryAddSingleton <IAS400ValueGeneratorCache, AS400ValueGeneratorCache>();
                b.TryAddSingleton <IAS400Options, AS400Options>();
                b.TryAddScoped <IAS400UpdateSqlGenerator, AS400UpdateSqlGenerator>();
                b.TryAddScoped <IAS400SequenceValueGeneratorFactory, AS400SequenceValueGeneratorFactory>();
                b.TryAddScoped <IAS400RelationalConnection, AS400RelationalConnection>();
            });
            builder.TryAddCoreServices();
            return(serviceCollection);
        }
        public static IServiceCollection AddEntityFrameworkAse(this IServiceCollection serviceCollection)
        {
            var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)

                          /*
                           * .TryAdd<IDatabaseProvider, DatabaseProvider<AseOptionsExtension>>()
                           * .TryAdd<IValueGeneratorCache>(s => s.GetService<IAseValueGeneratorCache>())
                           * .TryAdd<IRelationalTypeMappingSource, AseTypeMappingSource>()
                           * .TryAdd<ISqlGenerationHelper, AseSqlGenerationHelper>()
                           * //.TryAdd<IMigrationsAnnotationProvider, AseMigrationsAnnotationProvider>()
                           * //.TryAdd<IModelValidator, AseModelValidator>()
                           * //.TryAdd<IConventionSetBuilder, AseConventionSetBuilder>()
                           * .TryAdd<IUpdateSqlGenerator>(p => p.GetService<IAseServerUpdateSqlGenerator>())
                           * .TryAdd<ISingletonUpdateSqlGenerator>(p => p.GetService<IAseServerUpdateSqlGenerator>())
                           * .TryAdd<IModificationCommandBatchFactory, AseModificationCommandBatchFactory>()
                           * //.TryAdd<IValueGeneratorSelector, AseValueGeneratorSelector>()
                           * .TryAdd<IRelationalConnection>(s => s.GetService<IAseRelationalConnection>())
                           * //.TryAdd<IMigrationsSqlGenerator, AseMigrationsSqlGenerator>()
                           * //.TryAdd<IRelationalDatabaseCreator, AseDatabaseCreator>()
                           * //.TryAdd<IHistoryRepository, AseHistoryRepository>()
                           * //.TryAdd<ICompiledQueryCacheKeyGenerator, AseCompiledQueryCacheKeyGenerator>()
                           * //.TryAdd<IExecutionStrategyFactory, AseExecutionStrategyFactory>()
                           * .TryAdd<IQueryCompilationContextFactory, AseQueryCompilationContextFactory>()
                           * .TryAdd<IMemberTranslator, AseCompositeMemberTranslator>()
                           * .TryAdd<ICompositeMethodCallTranslator, AseCompositeMethodCallTranslator>()
                           * .TryAdd<IQuerySqlGeneratorFactory, AseQuerySqlGeneratorFactory>()
                           * //.TryAdd<ISqlTranslatingExpressionVisitorFactory, AseSqlTranslatingExpressionVisitorFactory>()
                           * //.TryAdd<ISingletonOptions, IAseOptions>(p => p.GetService<IAseOptions>())
                           * .TryAddProviderSpecificServices(
                           *  b => b
                           *      .TryAddSingleton<IAseValueGeneratorCache, AseValueGeneratorCache>()
                           *      //        .TryAddSingleton<IAseOptions, AseOptions>()
                           *      .TryAddSingleton<IAseServerUpdateSqlGenerator, AseServerUpdateSqlGenerator>()
                           *      //        .TryAddSingleton<IAseSequenceValueGeneratorFactory, AseSequenceValueGeneratorFactory>()
                           *      .TryAddScoped<IAseRelationalConnection, AseRelationalConnection>()
                           *      );
                           */

                          .TryAdd <LoggingDefinitions, AseLoggingDefinitions>()
                          .TryAdd <IDatabaseProvider, DatabaseProvider <AseOptionsExtension> >()
                          .TryAdd <IValueGeneratorCache>(p => p.GetService <IAseValueGeneratorCache>())
                          .TryAdd <IRelationalTypeMappingSource, AseTypeMappingSource>()
                          .TryAdd <ISqlGenerationHelper, AseSqlGenerationHelper>()
                          //.TryAdd<IMigrationsAnnotationProvider, AseMigrationsAnnotationProvider>()
                          //.TryAdd<IModelValidator, AseModelValidator>()
                          .TryAdd <IProviderConventionSetBuilder, AseConventionSetBuilder>()
                          .TryAdd <IUpdateSqlGenerator>(p => p.GetService <IAseUpdateSqlGenerator>())
                          .TryAdd <IModificationCommandBatchFactory, AseModificationCommandBatchFactory>()
                          .TryAdd <IValueGeneratorSelector, AseValueGeneratorSelector>()
                          .TryAdd <IRelationalConnection>(p => p.GetService <IAseConnection>())
                          //.TryAdd<IMigrationsSqlGenerator, AseMigrationsSqlGenerator>()
                          //.TryAdd<IRelationalDatabaseCreator, AseDatabaseCreator>()
                          //.TryAdd<IHistoryRepository, AseHistoryRepository>()
                          .TryAdd <ICompiledQueryCacheKeyGenerator, AseCompiledQueryCacheKeyGenerator>()
                          .TryAdd <IExecutionStrategyFactory, AseExecutionStrategyFactory>()
                          .TryAdd <ISingletonOptions, IAseOptions>(p => p.GetService <IAseOptions>())

                          .TryAdd <IQueryCompiler, AseQueryCompiler>()

                          // New Query Pipeline
                          .TryAdd <IMethodCallTranslatorProvider, AseMethodCallTranslatorProvider>()
                          .TryAdd <IMemberTranslatorProvider, AseMemberTranslatorProvider>()
                          .TryAdd <IQuerySqlGeneratorFactory, AseQuerySqlGeneratorFactory>()
                          //.TryAdd<IQueryTranslationPostprocessorFactory, AseQueryTranslationPostprocessorFactory>()
                          .TryAdd <IRelationalSqlTranslatingExpressionVisitorFactory, AseSqlTranslatingExpressionVisitorFactory>()
                          .TryAddProviderSpecificServices(
                b => b
                .TryAddSingleton <IAseValueGeneratorCache, AseValueGeneratorCache>()
                .TryAddSingleton <IAseOptions, AseOptions>()
                .TryAddSingleton <IAseUpdateSqlGenerator, AseUpdateSqlGenerator>()
                .TryAddSingleton <IAseSequenceValueGeneratorFactory, AseSequenceValueGeneratorFactory>()
                .TryAddScoped <IAseConnection, EfAseConnection>());

            builder.TryAddCoreServices();

            return(serviceCollection);
        }