0

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?

Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459
ae1112
  • 3
  • 3

1 Answers1

0

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.

Jack Ryan
  • 8,396
  • 4
  • 37
  • 76
  • Thanks for the hint, .ToList didn't work, but I ended up building a new User Defined Operator to get my window elements into a List and then return the TopK. – ae1112 Aug 21 '13 at 20:02