- 增加 ISelect.WhereCascade 实现多表查询时,向每个表中附加条件;

- 增加 Examples 项目 base_entity,利用 BaseEntity 实现简洁的数据库操作;
This commit is contained in:
28810
2019-07-19 18:35:58 +08:00
parent c403fa6fad
commit b37919be80
41 changed files with 745 additions and 171 deletions

View File

@ -41,6 +41,13 @@ namespace FreeSql.Internal
if (typeof(IEnumerable).IsAssignableFrom(entity) && entity.IsGenericParameter == true) return null;
if (entity.IsArray) return null;
object entityDefault = null;
try
{
if (entity.IsAbstract == false && entity.IsInterface == false)
entityDefault = Activator.CreateInstance(entity);
}
catch { }
var tbattr = common.GetEntityTableAttribute(entity);
trytb = new TableInfo();
trytb.Type = entity;
@ -148,7 +155,8 @@ namespace FreeSql.Internal
trytb.ColumnsByCsIgnore.Add(p.Name, col);
continue;
}
colattr.DbDefautValue = trytb.Properties[p.Name].GetValue(Activator.CreateInstance(trytb.Type));
if (entityDefault == null) entityDefault = Activator.CreateInstance(entity);
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)