This commit is contained in:
28810
2019-02-15 17:49:01 +08:00
parent 84449e57f3
commit 2ca55c3d15
18 changed files with 403 additions and 396 deletions

View File

@ -24,10 +24,10 @@ 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) {
internal static TableInfo GetTableByEntity(Type entity, CommonUtils common, bool isReCache = false) {
if (entity.FullName.StartsWith("<>f__AnonymousType")) return null;
var tbc = _cacheGetTableByEntity.GetOrAdd(common.DbName, k1 => new ConcurrentDictionary<Type, TableInfo>()); //区分数据库类型缓存
if (tbc.TryGetValue(entity, out var trytb)) return trytb;
if (isReCache == false && tbc.TryGetValue(entity, out var trytb)) return trytb;
if (common.CodeFirst.GetDbInfo(entity) != null) return null;
var tbattr = common.GetEntityTableAttribute(entity);
@ -105,7 +105,7 @@ namespace FreeSql.Internal {
foreach (var col in trytb.Primarys)
col.Attribute.IsPrimary = true;
}
tbc.TryAdd(entity, trytb);
tbc.AddOrUpdate(entity, trytb, (oldkey, oldval) => trytb);
#region virtual
if (common.CodeFirst.IsLazyLoading && propsLazy.Any()) {