我们可以通过db.CurrentConnectionConfig来设置更多参数,下面就是配置读写分离的例子
services.AddSqlSugar(new IocConfig() { ConnectionString = App.Configuration.GetConnectionString("SqlConnString"), DbType = IocDbType.SqlServer, IsAutoCloseConnection = true, }); services.ConfigurationSugar(db => { //设置更多连接参数 //db.CurrentConnectionConfig.XXXX=XXXX //db.CurrentConnectionConfig.MoreSettings=new ConnMoreSettings(){} //二级缓存设置 //db.CurrentConnectionConfig.ConfigureExternalServices = new ConfigureExternalServices() //{ // DataInfoCacheService = myCache //配置我们创建的缓存类 //} //读写分离设置 //laveConnectionConfigs = new List<SlaveConnectionConfig>(){...} /*多租户注意*/ //单库是db.CurrentConnectionConfig //多租户需要db.GetConnection(configId).CurrentConnectionConfig });
2016 © donet5.comApache Licence 2.0