我想从 IGrouping 查询中获取结果并将其放入列表中。
我试图这样做如下:
实体类
public class WordRank
{
public string Word { get; set; }
public string WordScore { get; set; }
}
方法
public void DisplayArticles()
{
var articles = this.articleRepository.TextMinerFindBy(this.view.Client, this.view.Brand, this.view.Project, this.view.Term, this.view.Channel, this.view.Begin, this.view.End, this.view.OnlyCategorized, this.view.UniquePosts);
string snippets = string.Empty;
foreach (var article in articles)
{
snippets = snippets + " " + article.Snippet;
}
Regex wordCountPattern = new Regex(@"[.,;:!?""\s-]");
string snippetCollection = wordCountPattern.Replace(snippets, " ");
var words = snippetCollection.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var groups = words.GroupBy(w => w);
foreach (var item in groups)
{
this.view.Words.Add(item);
}
}
但不可能将项目分配给 IList。任何人都可以给我光吗?
谢谢