How to Sort Order by LINQ query items alphabetically
I am using below LINQ query:
var data = (from x in _repository.GetAllMappingDetails().ToList()
join w in _repository.GetScenarioDDL().ToList() on x.FdpScenario equals w.CombinedName
where w.StudyId == selectedStudyId
orderby w.ScenarioName
select new
{
ScenarioId = w.ScenarioId,
ScenarioName = w.ScenarioDisplayId + " | " + w.ScenarioName
}).Distinct().ToList();
In this LINQ, I am using orderby w.ScenarioName to sort items alphabetically.
But seems like the orderby w.ScenarioName doesn't work as still the query doesn't return sorted items alphabetically.
Please let me know what is wrong in my query and how can I sort the query items alphabetically??
Thank you in advance.