public IViewComponentResult Invoke() { List <CloudTags> countTags = new List <CloudTags>(); var tags = tagService.GetTags(); var postTags = postTagService.GetPostsTags(); foreach (var item in tags) { countTags.Add(new CloudTags { Id = item.Id, Content = item.Content, Count = postTags.Where(x => x.TagId == item.Id).Count() }); } return(View(countTags)); }