문제

I have the following query, and I''m trying to get the top 4 of TopicCounts by TCount:

  var bygroup = (from element in inputSplit
                group element by element.Text into groups
                from win in groups.TumblingWindow(TimeSpan.FromSeconds(10))
                select new TopicCounts
                    {
                     Topic = groups.Key,
                     TCount = win.Count(),
                     Score = win.Avg(element => element.Sen)
                     }
                ).OrderByDescending(x => x.TCount).Distinct().Take(4); 

I get the following error whenever I try to build:

'Microsoft.ComplexEventProcessing.Linq.IQStreamable' does not contain a definition for 'OrderByDescending' and no extension method 'OrderByDescending' accepting a first argument of type

'Microsoft.ComplexEventProcessing.Linq.IQStreamable' could be found (are you missing a using directive or an assembly reference?)

What am I missing?

도움이 되었습니까?

해결책

IQStreamable cannot be sorted as it is a stream (streams load elements as they are required, a sort requires the entire collection). In order to sort it you need to load the entire collection. This can be done by calling ToList before you sort, however if the collection is large you will end up with high memory usage.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top