我已经获得了以下代码片段,它们全部正常工作,并引入了我想要的数据,但它为我的搜索结果带来了太多数据。我想把它分解为300字。我找到了我需要附加到描述字段的代码,但我不确定如何做到这一点。我相信将采用前300个单词的代码是
Split(' ').Take(300).Aggregate((a, b) => a + " " + b);
我正在使用的linq代码如下:
searchResults.DataSource = from r in response.Results
select new
{
Title = r[SearchContentProperty.Title],
Summary = r[SearchContentProperty.HighlightedSummary],
Id = r[SearchContentProperty.Id] * 10,
Quicklink = r[SearchContentProperty.QuickLink],
Description = r[SearchContentProperty.Description]
};
答案 0 :(得分:2)
怎么样
searchResults.DataSource = from r in response.Results
select new
{
Title = r[SearchContentProperty.Title],
Summary = r[SearchContentProperty.HighlightedSummary],
Id = r[SearchContentProperty.Id] * 10,
Quicklink = r[SearchContentProperty.QuickLink],
Description = r[SearchContentProperty.Description].ToString().Split(' ').Take(300).Aggregate((a, b) => a + " " + b);
};