airjsorsdanjkp
New Member
My scenario is: I have a class called \[code\]MenuBO\[/code\] using linq, it has a function called \[code\]SelectAll()\[/code\] that returns a list of the object \[code\]menu\[/code\] to use as a \[code\]DataSource\[/code\] for a \[code\]DropDownList\[/code\]. Before returning it I need to insert in the list a new item to serve as a default value for the \[code\]DropDownList\[/code\]Here's what I tried so far:\[code\]public List<menu> SelectAll(){ using (var db = new SeloQual_AdminEntities(conn)) { menu vmenu = new menu(); vmenu.cod_menu = 0; vmenu.cod_menu_pai = null; vmenu.des_menu = "Select..."; var query = from p in db.menu orderby p.des_menu select p; var test = query.ToList(); test.Add(vmenu); return test.OrderBy(x => x.cod_menu).ToList(); }}\[/code\]The \[code\]OrderBy(x => x.cod_menu)\[/code\] does it job, the \[code\]vmenu\[/code\] item appears on top like I want, but I need that the other items to be ordered by \[code\]des_menu\[/code\]. I tried something like\[code\]return teste.OrderBy(x => x.cod_menu).ThenBy(y => y.des_menu).ToList();\[/code\]But didn't work of course, so I some need help to order only the elements after the first one