Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do I get data in ascending order
my query is

var rec1 = (from ob in db.tbl_admission_master where (ob.class_div_id == x) select new { ob.roll_no, ob.tbl_registration_master.stud_name });
Posted

You should use OrderBy() which takes argument.

Sample is given below:
var result = (from c in products select c).OrderBy(x => x.ProductName).ToList();

ProductName: I want to display Product's name in ascending order.

for more information visit:
http://stackoverflow.com/questions/388708/ascending-descending-in-linq-can-one-change-the-order-via-parameter[^]
 
Share this answer
 
Try:
C#
var rec1 = (from ob in db.tbl_admission_master where (ob.class_div_id == x) orderby ob.roll_no select new { ob.roll_no, ob.tbl_registration_master.stud_name });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900