private bool GetDept(string code) { try { lock (deptobj) { deptList.AddRange(oc.BllSession.ISYS_DEPTService.Entities.Where(o => o.DEPT_CODE == code)); var list = oc.BllSession.ISYS_DEPTService.Entities.Where(o => o.PARENT_CODE == code); deptList.AddRange(list); if (list.Count() > 0) { foreach (var item in list) { GetDept(item.DEPT_CODE); } } return(true); } } catch (Exception ex) { RecordLog.RecordException(ex); return(false); } }