请教:为什么SimpleClient 不用继承IDisposable? (autofac 注入) 返回

SqlSugar 老数据
2 2249

请教:

  1. 为什么SimpleClient 不用继承IDisposable?


  2. 用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)