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?