views:

30

answers:

1

Hello everyone, I have the following LinqToEntities query, but am unsure of where or how to add the orderby clause:

     var results = 
                        from d in db.TBLDESIGNER
                        join s in db.TBLDESIGN on d.ID equals s.TBLDESIGNER.ID
                        where s.COMPLETED && d.ACTIVE
                        let value = new { s, d}
                        let key = new { d.ID, d.FIRST_NAME, d.LAST_NAME }
                        group value by key into g
orderby g.Key.FIRST_NAME ascending, g.Key.LAST_NAME ascending

                        select new
                        {
                            ID = g.Key.ID,
                            FirstName = g.Key.FIRST_NAME,
                            LastName = g.Key.LAST_NAME,
                            Count = g.Count()
                        };

This should be sorted by First_Name ascending and then Last_Name ascending.

I have tried adding ordering but It has had no effect on the result set. Could someone please provide an example of where the orderby would go assuming the query above. Thanks, Billy

A: 

see the updated version above. Where i added:

orderby g.Key.FIRST_NAME ascending, g.Key.LAST_NAME ascending
Billy Logan