Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple orderby in this linq code

How do I add a second item to order by with this? I want to order by a goalsScored element too.

var theteams = 
    (from teams in xdoc.Descendants("team")
     orderby (int)teams.Element("points") descending                               
     select 
         new Team(teams.Element("teamID").Value, 
                  (int)teams.Element("points"))                                
      ).Take(3);

but thenby doesn't seem to slot in to this query.

like image 390
Johnno Nolan Avatar asked Jan 31 '09 21:01

Johnno Nolan


1 Answers

var theteams =     
    (from teams in xdoc.Descendants("team")
    orderby (int)teams.Element("points") descending, OtherField1, OtherField2
    select new Team(teams.Element("teamID").Value,
    (int)teams.Element("points"))).Take(3);
like image 194
tsilb Avatar answered Oct 12 '22 16:10

tsilb