SqlSugarClient 和 SqlSugarScope差别在什么呢? 返回
在
public class SqliteDbContext
{
public static SqlSugarClient Current
{
get
{
var ConnectionString = @"datasource=" + System.AppDomain.CurrentDomain.BaseDirectory + @"Database\beltdatabase.db";
var client = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = ConnectionString,
DbType = SqlSugar.DbType.Sqlite,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.SystemTable,
ConfigureExternalServices = new ConfigureExternalServices()
{
// DataInfoCacheService = new RedisCache()
},
MoreSettings = new ConnMoreSettings()
{
IsAutoRemoveDataCache = true
},
});
return client;
}
}
}
使用 这样方法
/// <summary>
/// 查询所有数据(无分页,请慎用)
/// </summary>
/// <returns></returns>
public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
{
return Current.Queryable<T>( ).WithCacheIF(useCache ,cacheSecond).ToList();
}
上面使用没有问题,但是如果
var client = new SqlSugarScope(new ConnectionConfig()。。。 就报错
报错问题是
未能从程序集“SqlSugar, Version=5.0.3.0, Culture=neutral, PublicKeyToken=null”中加载类型“SqlSugar.SqlSugarScope”。
热忱回答(3)
-
永不放弃! VIP0
2021/9/12说明是在 net framework4.6中使用的
0 回复 -
fate stay night VIP0
2021/9/12@永不放弃!: SqlSugar, Version=5.0.3.0 版本不支持 ,需要升级到 5.4
0 回复 -
fate stay night VIP0
2021/9/12你看错误提示也看出来了你的DLL安装未到位
0 回复