You need to have a using
for System.Linq
to access the LINQ extension methods.
Also note that OrderBy
doesn't mutate the sequence, it creates a new sequence that is ordered.
Question
Please refer below code
public class NNAEmployeeDetails
{
public string DealerCode { get; set; }
public string EmployeeCode { get; set; }
public string EmployeeName { get; set; }
}
IEnumerable<NNAEmployeeDetails> empList =GetList();
i am trying the sort the above ienumerable by Employeename by below code
empList.OrderBy(s=>s.EmployeeName)
but OrderBy itself not showing in empList. Please refer below image
why the OrderBy is not coming in empList ? is any namespace problem ? what is the exact behavior ? how to sort ienumerable by EmployeeName ?
Solution
You need to have a using
for System.Linq
to access the LINQ extension methods.
Also note that OrderBy
doesn't mutate the sequence, it creates a new sequence that is ordered.