Upgrade from 4.5.6 to 4.5.8

In ServiceStatck.OrmLite 4.5.6, It works fine. the project is based on Sqlserver 2008 R2, .net framework 4.6.2,

After Upgrade to 4.5.8, It Doesn’t work. the connection state is open ,


but want to get data , It will occur a error, System.InvalidOperationException, the connection is closed

is there anything I write wrong?

Can you provide a stand-alone example we can run locally to see the issue?

I’m sorry , I think my code is also not works in 4.5.6.

if I wirte the code like the under, I found the Db will dispose before getdata, So will get errors.

    public class TestService1 : Service
    {
        static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
        public async Task<List<WX_RSGL_ZGDA>> GetData()
        {
            var testUserList = await Db.SelectAsync<WX_RSGL_ZGDA>();
            logger.Info($"testUserList: {testUserList.SerializeToString()}");
            return testUserList;
        }
    }

If I write the code like the under , It works fine.

  public class TestService2 : Service
    {
        static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
        public async Task<List<WX_RSGL_ZGDA>> GetData()
        {
            using (var Db = HostContext.Resolve<AppService>().Db)
            {
                var testUserList = await Db.SelectAsync<WX_RSGL_ZGDA>();
                logger.Info($"testUserList: {testUserList.SerializeToString()}");
                return testUserList;
            }
        }
    }

If I want to used the code like TestService1 , how to set will getdata before the Db Dispose?

Can you show how do you call GetData () in the first case?

I’m sorry, I have found the wrong and had to fixed it . thanks .