mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Optimized code
This commit is contained in:
@@ -26,8 +26,9 @@ namespace SqlSugar
|
||||
var pIdProp = entityInfo.Type.GetProperty(pIdName);
|
||||
var childProp = entityInfo.Type.GetProperty(childName);
|
||||
|
||||
var kvList = list.ToDictionary(x => mainIdProp.GetValue(x).ObjToString());
|
||||
var group = list.GroupBy(x => pIdProp.GetValue(x).ObjToString());
|
||||
Dictionary<string, T> kvList;
|
||||
IEnumerable<IGrouping<string, T>> group;
|
||||
BuildTreeGroup(list, mainIdProp, pIdProp, out kvList, out group);
|
||||
|
||||
var root = rootValue != null ? group.FirstOrDefault(x => x.Key == rootValue.ObjToString()) : group.FirstOrDefault(x => x.Key == null || x.Key == "" || x.Key == "0" || x.Key == Guid.Empty.ToString());
|
||||
|
||||
@@ -45,6 +46,12 @@ namespace SqlSugar
|
||||
return root;
|
||||
}
|
||||
|
||||
private static void BuildTreeGroup<T>(IEnumerable<T> list, PropertyInfo mainIdProp, PropertyInfo pIdProp, out Dictionary<string, T> kvList, out IEnumerable<IGrouping<string, T>> group)
|
||||
{
|
||||
kvList = list.ToDictionary(x => mainIdProp.GetValue(x).ObjToString());
|
||||
group = list.GroupBy(x => pIdProp.GetValue(x).ObjToString());
|
||||
}
|
||||
|
||||
internal static bool? _IsErrorDecimalString { get; set; }
|
||||
internal static bool? IsErrorDecimalString()
|
||||
{
|
||||
|
Reference in New Issue
Block a user