0

我有下面的代码片段,它的所有工作,并引入了我想要的数据,但它为我的搜索结果带来了太多的数据。我想把它分解成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]
                               };
4

1 回答 1

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);
                           };
于 2012-06-28T22:15:51.897 回答