private void ClearRelationCache(int?fromId) { if (fromId == null) { _rootRelations = null; } else { _relations.Remove(fromId.Value); } }
private LinkedList <DbRelation> GetCacheRelationsByParent(int?fromId) { CacheRelationList list; if (fromId == null) { list = _rootRelations; } else { _relations.TryGetValue(fromId.Value, out list); } if (list == null) { list = new CacheRelationList { FromId = fromId }; var relationsFromDb = _dataService.GetRelations(fromId); if (relationsFromDb != null) { foreach (var relation in relationsFromDb) { list.AddLast(relation); } } if (fromId == null) { _rootRelations = list; } else { _relations[fromId.Value] = list; } } return(list); }