You did not order groups; you need to do this before you can make the page. For example:
.GroupBy(c => c.Reference).OrderBy(grp => grp.Key).Skip(x).Take(100);
(you can also replace OrderByDescending if you want the groups to be in reverse order)
Also: as you group, the order in the source data is pretty much pointless; you could remove OrderByDescending(c => c.TimeStamp) .
So the net result is:
var query = container.CoinMessageSet.Where( c => c.MessageState != MessageStateType.Closed && (c.DonorOperator.OperatorCode.Equals("opcode") || c.RecipientOperator.OperatorCode.Equals("opcode")) ).GroupBy(c => c.Reference).OrderBy(grp => grp.Key) .Skip(x).Take(100);
or perhaps:
var query = (from c in container.CoinMessageSet where c.MessageState != MessageStateType.Closed && (c.DonorOperator.OperatorCode == "opcode" || c.RecipientOperator.OperatorCode == "opcode") group c by c.Reference into grp orderby grp.Key select grp).Skip(x).Take(100);
Marc gravell
source share