c# - Linq GroupBy Clause -


var result = rows.groupby(x => new { y = x["academicyearid"] })     .select(         g => new         {             academicyearid = g.key.y,             classgroups = g.groupby(x => new { y = x["classname"], h = x["classgroupid"], = x["classyearid"] })             .select(                 classyear => new                 {                     classname = classyear.key.y,                     classgroupid = classyear.key.h,                     classyearid=classyear.key.i,                     classdivisions = classyear.groupby(x => new { b = x["division"], = x["divisionid"] })                     .select(                     clsdiv => new                     {                         divisionid = clsdiv.key.a,                         division = clsdiv.key.b                                                    })                 })         }); 

this working code, want "classdivisions" orderby division. do that?

is want?

var result =     rows         .groupby(x => new { y = x["academicyearid"] })         .select(g => new         {             academicyearid = g.key.y,             classgroups =                 g                     .groupby(x => new { y = x["classname"], h = x["classgroupid"], = x["classyearid"] })                     .select(classyear => new                     {                         classname = classyear.key.y,                         classgroupid = classyear.key.h,                         classyearid=classyear.key.i,                         classdivisions =                             classyear                                 .groupby(x => new { b = x["division"], = x["divisionid"] })                                 .select(clsdiv => new                                 {                                     divisionid = clsdiv.key.a,                                     division = clsdiv.key.b                                                                })                                 .orderby(clsdiv => clsdiv.division)                     })         }); 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -