Skip to content

Commit 2d6cb80

Browse files
committed
- 修复 非公开无参的实体无法获取默认值问题;#2085
1 parent b337c4b commit 2d6cb80

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

FreeSql/Internal/UtilsExpressionTree.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ internal static TableInfo GetTableByEntity(Type entity, CommonUtils common)
7474
try
7575
{
7676
if (entity.IsAbstract == false && entity.IsInterface == false)
77-
entityDefault = Activator.CreateInstance(entity);
77+
entityDefault = Activator.CreateInstance(entity, true);
7878
}
7979
catch { }
8080
var tbattr = common.GetEntityTableAttribute(entity);
@@ -2798,7 +2798,7 @@ Expression LocalFuncGetExpression(bool ignoreArray = false)
27982798
}
27992799
public static object GetDataReaderValue(Type type, object value)
28002800
{
2801-
//if (value == null || value == DBNull.Value) return Activator.CreateInstance(type);
2801+
//if (value == null || value == DBNull.Value) return Activator.CreateInstance(type, true);
28022802
if (type == null) return value;
28032803
var valueType = value?.GetType() ?? type;
28042804
if (TypeHandlers.TryGetValue(valueType, out var typeHandler)) return typeHandler.Serialize(value);

0 commit comments

Comments
 (0)