c# - Linq Sorted Groupby and Orderby fields -


i feel on edge of answer!

i have custom fileinfo class holders info such "reporting store number" , "report date" etc...

i have list<fileinfo> hold file information. have attempted group list "reporting store number" , order "report date"

i have come following

var results = ownedfileinfo.groupby(x => x.reportstore).select(group=> new { keyname = group.key, keyinfo =  group.orderby(x=>x.reportdate).thenby(x=>x.reportstore)});  list<fileinfo> sortedfiles = new list<fileinfo>();                     foreach (var group in results)                     {                          foreach (fileinfo fi in group.keyinfo)                         {                             sortedfiles.add(fi);                          }                     } 

the groupby , orderby functionality working expected. although hoping thenby sort groupby column :(

results:

  • store#.....date
  • 991........10/16/13
  • 991........10/17/13
  • 994........10/16/13
  • 994........10/17/13
  • 992........10/16/13
  • 992........10/17/13

expected results:

  • store#.....date
  • 991........10/16/13
  • 991........10/17/13
  • 992........10/16/13
  • 992........10/17/13
  • 994........10/16/13
  • 994........10/17/13

could 1 of more experience linq please point out missing or whats going wrong? thank in advanced time.

i not think output need grouping @ all:

var sortedfiles = ownedfileinfo.orderby(x => x.reportstore)                                .thenby(x => x.reportdate)                                .tolist(); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -