标签:ace console sql index ble ast exec aop client
如果配置了 SlaveConnectionConfigs那就是主从模式,所有的写入删除更新都走主库,查询走从库,事务内都走主库,HitRate表示权重 值越大执行的次数越高,如果想停掉哪个连接可以把HitRate设为0
SqlSugarClient db = new SqlSugarClient( new ConnectionConfig() { ConnectionString = Config.ConnectionString, //主连接 DbType = DbType.SqlServer, IsAutoCloseConnection = true , SlaveConnectionConfigs = new List<SlaveConnectionConfig>() { //从连接 new SlaveConnectionConfig() { HitRate=10, ConnectionString=Config.ConnectionString2 }, new SlaveConnectionConfig() { HitRate=30, ConnectionString=Config.ConnectionString3 } }}); |
我们可以用AOP来查看所有操作执行的连接字符串是哪个
db.Aop.OnLogExecuting = (sql, pars) => { Console.WriteLine(db.Ado.Connection.ConnectionString); }; |
强制走主库4.9.9.4
db.Ado.IsDisableMasterSlaveSeparation= true |
标签:ace console sql index ble ast exec aop client
原文地址:https://www.cnblogs.com/Jeely/p/11357167.html