This project is read-only.

Group & Sum with CLINQ

Mar 18, 2009 at 7:35 PM
Edited Mar 18, 2009 at 7:36 PM
I've been trying to get a view into an ObservableCollection and populate the view with grouped and summed rows - unfortunately my current implementation is throwing the following exception:

CLINQ does not support expressions of type: Lambda

I have an ObservableCollection<Record> where Record consists of the following properties:

I want to get a view that is sorted by Price, groups records with the same Name at the same Price and sums the associated Size.

Ideally a model that contains the following data:

Orderid       Name       Price       Size
101             John         7.25        100
102             Fred         8.00        125
103             John         7.25        200
104             Fred         7.25        150

Would produce the following view:

Name          Price        Size
John            7.25         300
Fred            7.25         150
Fred            8.00         125

I tried to use CLINQ to create a view like this with the following:

ReadOnlyContinuousCollection<Record> monitorTable = from record in observableTable
                                                                                                 where record.Price > 0.0
                                                                                                 group record by new {Price = record.Price, Name = record.Name}
                                                                                                 into byprice
                                                                                                         select new Record(byprice.Key.Name, byprice.Key.Price, byprice.Sum(r => r.Size));

And received the above referenced exception.
Does anyone have an idea about the best way to accomplish this?