Optimize the details

This commit is contained in:
sunkaixuan
2022-05-16 13:15:52 +08:00
parent 1003691b6f
commit b5b2e79a16

View File

@@ -333,17 +333,17 @@ namespace SqlSugar
{ {
l, l,
n n
}).GroupBy(it=>it.l).ToList(); }).GroupBy(it => it.l).ToList();
foreach (var item in GroupQuery) foreach (var item in GroupQuery)
{ {
if (sqlObj.MappingExpressions.HasValue()) if (sqlObj.MappingExpressions.HasValue())
{ {
MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>(); MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>();
helper.NavEntity = navEntityInfo; helper.NavEntity = navEntityInfo;
helper.Context = this.Context; helper.Context = this.Context;
helper.RootEntity = this.Context.EntityMaintenance.GetEntityInfo<T>(); helper.RootEntity = this.Context.EntityMaintenance.GetEntityInfo<T>();
helper.SetChildList(navObjectNameColumnInfo, item.Key,item.Select(it=>it.n).ToList(),sqlObj.MappingExpressions); helper.SetChildList(navObjectNameColumnInfo, item.Key, item.Select(it => it.n).ToList(), sqlObj.MappingExpressions);
} }
else else
{ {
@@ -359,13 +359,22 @@ namespace SqlSugar
} }
foreach (var item in list) foreach (var item in list)
{ {
if (navObjectNamePropety.GetValue(item) == null) if (navObjectNamePropety.GetValue(item) == null)
{ {
var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true); var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true);
navObjectNamePropety.SetValue(item, instance); navObjectNamePropety.SetValue(item, instance);
} }
} }
} }
else
{
//No navigation data set new List()
foreach (var item in list)
{
var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true);
navObjectNamePropety.SetValue(item, instance);
}
}
} }
} }