sqlsugar.ioc 1.4版本开始支持设置AOP , 当前类库需要引用SqlSugarCore.dll
services.AddSqlSugar(new IocConfig() { ConnectionString = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST", DbType = IocDbType.SqlServer, IsAutoCloseConnection = true }); services.ConfigurationSugar(db => { db.Aop.OnLogExecuting = (sql, p) => { Console.WriteLine(sql); }; //设置更多连接参数 //db.CurrentConnectionConfig });
请:升级到1.5
services.AddSqlSugar(new IocConfig() { ConfigId="1", ConnectionString = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST", DbType = IocDbType.SqlServer, IsAutoCloseConnection = true }); services.AddSqlSugar(new IocConfig() { ConfigId="2", ConnectionString = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST2", DbType = IocDbType.SqlServer, IsAutoCloseConnection = true }); services.ConfigurationSugar(db => { db.GetConnection("1").Aop.OnLogExecuting = (sql, p) => { Console.WriteLine(sql); }; db.GetConnection("2").Aop.OnLogExecuting = (sql, p) => { Console.WriteLine(sql); }; //如果你用到GetConnectionScope这边注入也应该是GetConnectionScope //设置更多连接参数 //db.GetConnection("1").CurrentConnectionConfig });
2016 © donet5.comApache Licence 2.0