コード例 #1
0
ファイル: Startup.cs プロジェクト: 1100100/Dapper.Extensions
        public void ConfigureContainer(ContainerBuilder builder)
        {
            #region Add Dapper
            //builder.AddDapperForMySQL();

            //builder.AddDapperForMySQL("MySqlConnection", "mysql-conn");

            //builder.AddDapperForMSSQL("MSSqlConnection", "msql-conn");

            //builder.AddDapperForSQLite("SQLite1Connection", "sqlite1-conn");

            //builder.AddDapperForSQLite("SQLite2Connection", "sqlite2-conn");

            builder.AddDapperForSQLite("master_slave", "master_slave", true, monitorBuilder =>
            {
                monitorBuilder.Threshold = 0;
                monitorBuilder.EnableLog = true;
                monitorBuilder.AddMonitorHandler <MyMonitorHandler>();
            });

            //builder.AddDapperForSQLite("SQLite1Connection", monitorBuilder: monitorBuilder =>
            // {
            //     monitorBuilder.Threshold = 0;
            //     monitorBuilder.EnableLog = true;
            //     monitorBuilder.AddMonitorHandler<MyMonitorHandler>();
            // });

            //Add support for MiniProfiler
            //builder.AddMiniProfilerForDapper();

            //builder.AddSQLSeparationForDapper(Path.Combine(Directory.GetCurrentDirectory(), "sql"));
            //builder.AddDapperConnectionStringProvider<CustomConnectionStringProvider>();

            #endregion

            #region Enable Caching

            //builder.AddDapperCachingForRedis(new RedisConfiguration
            //{
            //    AllMethodsEnableCache = false,
            //    ConnectionString = "127.0.0.1:6379,password=nihao123",
            //    Expire = TimeSpan.FromHours(1)
            //});

            //builder.AddDapperCachingInPartitionRedis(new PartitionRedisConfiguration
            //{
            //    Connections = new[] { "localhost:6379,password=nihao123#@!,defaultDatabase=1", "localhost:6379,password=nihao123#@!,defaultDatabase=2" }
            //});

            //builder.AddDapperCachingInMemory(new MemoryConfiguration
            //{
            //    AllMethodsEnableCache = false
            //});

            #endregion

            builder.AddAllControllers();
        }