diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs index 59f596690..4f5b47c10 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs @@ -333,17 +333,17 @@ namespace SqlSugar { l, n - }).GroupBy(it=>it.l).ToList(); + }).GroupBy(it => it.l).ToList(); foreach (var item in GroupQuery) { - + if (sqlObj.MappingExpressions.HasValue()) { MappingFieldsHelper helper = new MappingFieldsHelper(); helper.NavEntity = navEntityInfo; helper.Context = this.Context; helper.RootEntity = this.Context.EntityMaintenance.GetEntityInfo(); - 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 { @@ -359,13 +359,22 @@ namespace SqlSugar } foreach (var item in list) { - if (navObjectNamePropety.GetValue(item) == null) + if (navObjectNamePropety.GetValue(item) == null) { var instance = Activator.CreateInstance(navObjectNamePropety.PropertyType, true); 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); + } + } } }