mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
修复 外部配置实体ConfigEntity 与 延时加载 冲突产生的 bug
This commit is contained in:
parent
8e4d3c03a5
commit
a2f4a8bcd8
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Version>0.1.5.3</Version>
|
||||
<Version>0.1.6</Version>
|
||||
<Authors>YeXiangQin</Authors>
|
||||
<Description>FreeSql 通用仓库层现实,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
|
||||
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Version>0.1.5</Version>
|
||||
<Version>0.1.6</Version>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>YeXiangQin</Authors>
|
||||
<Description>打造 .NETCore 最方便的 ORM,DbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
|
||||
|
@ -39,7 +39,7 @@ namespace FreeSql.Internal {
|
||||
var table = dicConfigEntity.GetOrAdd(type, new TableAttribute());
|
||||
var fluent = new TableFluent<T>(table);
|
||||
entity.Invoke(fluent);
|
||||
Utils.GetTableByEntity(type, this, true); //update cache
|
||||
Utils.RemoveTableByEntity(type, this); //remove cache
|
||||
return _orm.CodeFirst;
|
||||
}
|
||||
internal ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) {
|
||||
@ -47,7 +47,7 @@ namespace FreeSql.Internal {
|
||||
var table = dicConfigEntity.GetOrAdd(type, new TableAttribute());
|
||||
var fluent = new TableFluent(type, table);
|
||||
entity.Invoke(fluent);
|
||||
Utils.GetTableByEntity(type, this, true); //update cache
|
||||
Utils.RemoveTableByEntity(type, this); //remove cache
|
||||
return _orm.CodeFirst;
|
||||
}
|
||||
internal TableAttribute GetConfigEntity(Type type) {
|
||||
|
@ -24,10 +24,15 @@ namespace FreeSql.Internal {
|
||||
class Utils {
|
||||
|
||||
static ConcurrentDictionary<string, ConcurrentDictionary<Type, TableInfo>> _cacheGetTableByEntity = new ConcurrentDictionary<string, ConcurrentDictionary<Type, TableInfo>>();
|
||||
internal static TableInfo GetTableByEntity(Type entity, CommonUtils common, bool isReCache = false) {
|
||||
internal static void RemoveTableByEntity(Type entity, CommonUtils common) {
|
||||
if (entity.FullName.StartsWith("<>f__AnonymousType")) return;
|
||||
var tbc = _cacheGetTableByEntity.GetOrAdd(common.DbName, k1 => new ConcurrentDictionary<Type, TableInfo>()); //区分数据库类型缓存
|
||||
tbc.TryRemove(entity, out var trytb);
|
||||
}
|
||||
internal static TableInfo GetTableByEntity(Type entity, CommonUtils common) {
|
||||
if (entity.FullName.StartsWith("<>f__AnonymousType")) return null;
|
||||
var tbc = _cacheGetTableByEntity.GetOrAdd(common.DbName, k1 => new ConcurrentDictionary<Type, TableInfo>()); //区分数据库类型缓存
|
||||
if (isReCache == false && tbc.TryGetValue(entity, out var trytb)) return trytb;
|
||||
if (tbc.TryGetValue(entity, out var trytb)) return trytb;
|
||||
if (common.CodeFirst.GetDbInfo(entity) != null) return null;
|
||||
|
||||
var tbattr = common.GetEntityTableAttribute(entity);
|
||||
|
Loading…
x
Reference in New Issue
Block a user