SqlSugarCore不支持.NetCore3.1吗? 返回
protected SqlSugarClient GetDbContext(string connectionString)
{
try
{
var dbContext = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = connectionString,
DbType = DbType.SqlServer,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true
});
Console.WriteLine($"[BaseSugarRepository] ConnectionString:{connectionString}");
dbContext.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine("[BaseSugarRepository] " + sql + "\r\n" + dbContext.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
};
return dbContext;
}
catch (Exception ex)
{
Console.WriteLine($"[BaseSugarRepository Exception] Message:{ex.Message}, StackTrace:{ex.StackTrace}");
throw new Exception("Failed to connect database. Please check the connection string and network connection", ex);
}
}
==============================================================
public async Task<ConfigEntity> GetConfiguration()
{
using (var dbContext = GetDbContext(_connectionStrings.SqlServerConnection))
{
return await dbContext.Queryable<ConfigEntity>().With(SqlWith.NoLock)
.Where(c => c.Type == (int) EnumConfigType.Special).OrderBy(o => o.Id, OrderByType.Desc)
.FirstAsync();
}
}
GetConfiguration()一直不返回数据
热忱回答(1)
-
fate stay night VIP0
2020/12/15肯定是支持的 有问题你自个用控制台写个DEMO
0 回复