コード例 #1
0
 public void ConfigureDesignTimeServices(IServiceCollection services)
 {
     new EntityFrameworkRelationalServicesBuilder(services).TryAddProviderSpecificServices(x =>
     {
         x.TryAddSingleton <INpgsqlOptions, NpgsqlOptions>(p =>
         {
             var dbOption = new DbContextOptionsBuilder()
                            .UseNpgsql("connection string",
                                       ob => ob.UseNodaTime().UseNetTopologySuite()).Options;
             var npgOptions = new NpgsqlOptions();
             npgOptions.Initialize(dbOption);
             return(npgOptions);
         });
     });
 }
コード例 #2
0
        static NpgsqlNodaTimeTypeMappingTest()
        {
            var optionsBuilder = new DbContextOptionsBuilder();
            var npgsqlBuilder  = new NpgsqlDbContextOptionsBuilder(optionsBuilder).UseNodaTime();
            var options        = new NpgsqlOptions();

            options.Initialize(optionsBuilder.Options);

            Mapper = new NpgsqlTypeMappingSource(
                new TypeMappingSourceDependencies(
                    new ValueConverterSelector(new ValueConverterSelectorDependencies())
                    ),
                new RelationalTypeMappingSourceDependencies(),
                options
                );
        }
        public NpgsqlTypeMappingSourceTest()
        {
            var builder = new DbContextOptionsBuilder();

            new NpgsqlDbContextOptionsBuilder(builder).MapRange <float>("floatrange");
            new NpgsqlDbContextOptionsBuilder(builder).MapRange <DummyType>("dummyrange", subtypeName: "dummy");
            var options = new NpgsqlOptions();

            options.Initialize(builder.Options);

            Source = new NpgsqlTypeMappingSource(
                new TypeMappingSourceDependencies(
                    new ValueConverterSelector(new ValueConverterSelectorDependencies()),
                    Array.Empty <ITypeMappingSourcePlugin>()),
                new RelationalTypeMappingSourceDependencies(
                    new[] { new DummyTypeMappingSourcePlugin() }),
                new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
                options);
        }