private void AddLeafToList <T>(IDbSession session, IHierarchyModel entity, List <T> rslList) where T : IHierarchyModel { var list = session.Query <T>().Where(h => h.Parent.Id == entity.Id).ToList(); if (list == null || list.Count == 0) { rslList.Add((T)entity); } foreach (var centity in list) { AddLeafToList(session, centity, rslList); } }
private void SetChilds(IDbSession session, IHierarchyModel item, List <PersonModel> results) { var childs = session.Query <IResource>().Where(c => c.IsUsed == true && c.Parent != null && c.Parent.Id == item.Id).ToList(); var childTypeIds = childs.Select(c => c.Id).ToList(); var materials = session.Query <PersonModel>().Where(c => c.IsUsed == true && childTypeIds.Contains(c.Area.Id)).ToList(); foreach (var mat in materials) { results.Add(mat); } foreach (var type in childs) { SetChilds(session, type, results); } }