- 修复 FreeSql.Repository GuidRepository/GetGuidRepository 缓存 bug;
- 修复 Lazy 延时加载在 linux 发布后产生 Bad IL Format bug;
This commit is contained in:
28810 2019-03-05 14:42:51 +08:00
parent a189b6abba
commit 45ba67ed15
4 changed files with 19 additions and 16 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Version>0.1.9</Version> <Version>0.1.10</Version>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>FreeSql 通用仓库层实现,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description> <Description>FreeSql 通用仓库层实现,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl> <PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>

View File

@ -17,15 +17,15 @@ public static class IFreeSqlExtenssions {
/// <returns></returns> /// <returns></returns>
public static DefaultRepository<TEntity, TKey> GetRepository<TEntity, TKey>(this IFreeSql that, Expression<Func<TEntity, bool>> filter = null) where TEntity : class { public static DefaultRepository<TEntity, TKey> GetRepository<TEntity, TKey>(this IFreeSql that, Expression<Func<TEntity, bool>> filter = null) where TEntity : class {
if (filter != null) return new DefaultRepository<TEntity, TKey>(that, filter);
return dicGetRepository return dicGetRepository
.GetOrAdd(typeof(TEntity), key1 => new ConcurrentDictionary<Type, ConcurrentDictionary<string, IRepository>>()) .GetOrAdd(typeof(TEntity), key1 => new ConcurrentDictionary<Type, IRepository>())
.GetOrAdd(typeof(TKey), key2 => new ConcurrentDictionary<string, IRepository>()) .GetOrAdd(typeof(TKey), key2 => new DefaultRepository<TEntity, TKey>(that, null)) as DefaultRepository<TEntity, TKey>;
.GetOrAdd(string.Concat(filter), key3 => new DefaultRepository<TEntity, TKey>(that, filter)) as DefaultRepository<TEntity, TKey>;
} }
static ConcurrentDictionary<Type, static ConcurrentDictionary<Type,
ConcurrentDictionary<Type, ConcurrentDictionary<Type,
ConcurrentDictionary<string, IRepository>> IRepository>
> dicGetRepository = new ConcurrentDictionary<Type, ConcurrentDictionary<Type, ConcurrentDictionary<string, IRepository>>>(); > dicGetRepository = new ConcurrentDictionary<Type, ConcurrentDictionary<Type, IRepository>>();
/// <summary> /// <summary>
/// 返回仓库类,适用 Insert 方法无须返回插入的数据 /// 返回仓库类,适用 Insert 方法无须返回插入的数据
@ -36,10 +36,9 @@ public static class IFreeSqlExtenssions {
/// <returns></returns> /// <returns></returns>
public static GuidRepository<TEntity> GetGuidRepository<TEntity>(this IFreeSql that, Expression<Func<TEntity, bool>> filter = null) where TEntity : class { public static GuidRepository<TEntity> GetGuidRepository<TEntity>(this IFreeSql that, Expression<Func<TEntity, bool>> filter = null) where TEntity : class {
if (filter != null) return new GuidRepository<TEntity>(that, filter);
return dicGetGuidRepository return dicGetGuidRepository
.GetOrAdd(typeof(TEntity), key1 => new ConcurrentDictionary<string, IRepository>()) .GetOrAdd(typeof(TEntity), key1 => new GuidRepository<TEntity>(that, filter)) as GuidRepository<TEntity>;
.GetOrAdd(string.Concat(filter), key2 => new GuidRepository<TEntity>(that, filter)) as GuidRepository<TEntity>;
} }
static ConcurrentDictionary<Type, static ConcurrentDictionary<Type, IRepository> dicGetGuidRepository = new ConcurrentDictionary<Type, IRepository>();
ConcurrentDictionary<string, IRepository>> dicGetGuidRepository = new ConcurrentDictionary<Type, ConcurrentDictionary<string, IRepository>>();
} }

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Version>0.1.9</Version> <Version>0.1.10</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors> <Authors>YeXiangQin</Authors>
<Description>打造 .NETCore 最方便的 ORMDbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description> <Description>打造 .NETCore 最方便的 ORMDbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>

View File

@ -545,14 +545,18 @@ return rTn;");
return Activator.CreateInstance(type) as ITemplateOutput; return Activator.CreateInstance(type) as ITemplateOutput;
} }
internal static Lazy<CSScriptLib.RoslynEvaluator> _compiler = new Lazy<CSScriptLib.RoslynEvaluator>(() => { internal static Lazy<CSScriptLib.RoslynEvaluator> _compiler = new Lazy<CSScriptLib.RoslynEvaluator>(() => {
var dlls = Directory.GetFiles(Directory.GetParent(Type.GetType("IFreeSql, FreeSql").Assembly.Location).FullName, "*.dll"); //var dlls = Directory.GetFiles(Directory.GetParent(Type.GetType("IFreeSql, FreeSql").Assembly.Location).FullName, "*.dll");
var compiler = new CSScriptLib.RoslynEvaluator(); var compiler = new CSScriptLib.RoslynEvaluator();
compiler.DisableReferencingFromCode = false; compiler.DisableReferencingFromCode = false;
compiler.DebugBuild = true; compiler.DebugBuild = true;
foreach (var dll in dlls) { //foreach (var dll in dlls) {
var ass = Assembly.LoadFile(dll); // Console.WriteLine(dll);
compiler.ReferenceAssembly(ass); // var ass = Assembly.LoadFile(dll);
} // compiler.ReferenceAssembly(ass);
//}
compiler
.ReferenceAssemblyOf<IFreeSql>()
.ReferenceDomainAssemblies();
return compiler; return compiler;
}); });