Problem with order by in LINQ

Posted by vikitor on Stack Overflow See other posts from Stack Overflow or by vikitor
Published on 2010-04-06T13:43:02Z Indexed on 2010/04/06 13:53 UTC
Read the original article Hit count: 412

Filed under:
|
|
|

Hi, I'm passing from the controller an array generated by the next code:

public ActionResult GetClasses(bool ajax, string kingdom)
        {
            int _kingdom = _taxon.getKingdom(kingdom);

            var query = (from c in vwAnimalsTaxon.All()
                         orderby c.ClaName
                         select new { taxRecID = c.ClaRecID, taxName = c.ClaName }).Distinct();

            return Json(query, JsonRequestBehavior.AllowGet);
        }

The query List should be ordered, but it doesn't work, I get the names of the classes ordered wrong in the array, because I've seen it debugging that the names are not ordered.The view is just a dropdownbox loaded automatically, so I'm almost sure the problem is with the action. Do you see anything wrong?Am I missing something?

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about c#