为多实例 不同表名规则情况下开放缓存机制,可使用MemoryCache等功能替换为实例缓存

避免全局静态缓存表名称无法替换
This commit is contained in:
hyzx86 2023-09-26 22:54:15 +08:00
parent 7926429393
commit 922f645249

View File

@ -19,8 +19,10 @@ namespace FreeSql.Internal
{ {
public class Utils public class Utils
{ {
public static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>> _cacheGetTableByEntity
static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>> _cacheGetTableByEntity = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>(); {
get; set;
} = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, TableInfo>>();
internal static void RemoveTableByEntity(Type entity, CommonUtils common) internal static void RemoveTableByEntity(Type entity, CommonUtils common)
{ {
if (entity.IsAnonymousType() || if (entity.IsAnonymousType() ||
@ -534,7 +536,7 @@ namespace FreeSql.Internal
{ {
col.Attribute.IsNullable = false; col.Attribute.IsNullable = false;
col.Attribute.DbType = col.Attribute.DbType.Replace("NOT NULL", "").Replace(" NULL", "").Trim(); col.Attribute.DbType = col.Attribute.DbType.Replace("NOT NULL", "").Replace(" NULL", "").Trim();
switch(common._orm.Ado.DataType) switch (common._orm.Ado.DataType)
{ {
case DataType.Sqlite: case DataType.Sqlite:
col.Attribute.DbType += " NOT NULL"; //sqlite 主键也可以插入 null col.Attribute.DbType += " NOT NULL"; //sqlite 主键也可以插入 null