Page 1 of 1

OrderByDescending Issue on Group By query

Posted: Thu 25 Feb 2010 16:07
by fastjem
Hello, Im getting an error while doing an Order by on a group by query

Code: Select all

var reportData = (from pr in db.PageReports
                  where pr.CampaignID == 594
                  group pr by pr.DeviceID into g
                  select new
                  {
                      DeviceID = g.Key,
                      DeviceCount = g.Count(),
                      Device = (from d in db.Devices
                                    where d.DeviceID == g.Key
                                    select d)
                  });

var finalData = reportData.OrderByDescending(s => s.DeviceCount);
The query will get the correct data, but as soon as I do the Order by I get the following error:

"Expression of type 'System.Decimal' cannot be used for constructor parameter of type 'System.Nullable`1[System.Decimal]'"

Thanks for the help.

Posted: Thu 25 Feb 2010 16:38
by AndreyR
I have just tried the similar code using the latest 5.70.97 build and succeeded.
I recommend you to upgrade to the latest build.

Posted: Thu 25 Feb 2010 19:35
by fastjem
Thanks that fixed it