- 优化 内部实体管理的默认值,防止导航属性使用抽象类/接口时出现错误;

This commit is contained in:
28810 2019-08-01 10:05:08 +08:00
parent 8a11e9c794
commit 49a1eecb45

View File

@ -155,8 +155,7 @@ namespace FreeSql.Internal
trytb.ColumnsByCsIgnore.Add(p.Name, col);
continue;
}
if (entityDefault == null) entityDefault = Activator.CreateInstance(entity);
colattr.DbDefautValue = trytb.Properties[p.Name].GetValue(entityDefault);
if (entityDefault != null) colattr.DbDefautValue = trytb.Properties[p.Name].GetValue(entityDefault);
if (colattr.DbDefautValue != null && p.PropertyType != colattr.MapType) colattr.DbDefautValue = Utils.GetDataReaderValue(colattr.MapType, colattr.DbDefautValue);
if (colattr.DbDefautValue == null) colattr.DbDefautValue = tp?.defaultValue;
if (colattr.IsNullable == false && colattr.DbDefautValue == null)