请教:为什么SimpleClient 不用继承IDisposable? (autofac 注入) 返回
请教:
为什么SimpleClient 不用继承IDisposable?
用autofac 注入了后,是否每次连接数据库不用使用using了
-------------------------------------------------
下面是以前没用autoface 的使用方法
using (var dbClient = db.GetInstance())
{
。。。。
}
--------------------------------------
下面是用了autoface注入,但我不太清楚它是否能自动释放连接
builder.Register<SqlSugarClient>(x =>
{
var client = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = SettingConfig.DBConnectionStrings ,
DbType = DbType.MySql,
IsAutoCloseConnection = true,
});
return client;
})
.AsSelf()
.AsImplementedInterfaces()
.InstancePerLifetimeScope();
热忱回答(2)
-
fate stay night VIP0
2019/5/16IsAutoCloseConnection = true,
0 回复 -
'猫猫Z VIP0
2019/5/16@fate stay night:thanks
0 回复