public async Task searchDir(int id) { List <FileSystemObject> fsoList = await _context.FileSystemObjects.ToListAsync(); IEnumerable <FileSystemObject> subDirList = new List <FileSystemObject>(); subDirList = from dir in fsoList where dir.ParentId == id select dir; foreach (var f in subDirList) { SearchScope.Add(f); if (f.IsFolder) { await searchDir(f.Id); } } }