Hi
I have below code but it is not sorting by Date
List Result = (from t in context.Sessions
where t.GroupID == GroupID
orderby t.SessionDate
select t).ToList();
Thanks
Hi
I have below code but it is not sorting by Date
List Result = (from t in context.Sessions
where t.GroupID == GroupID
orderby t.SessionDate
select t).ToList();
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Apr 2, 2023, 1:50 PM
If you only need to access the SessionDate property and not the entire Session object, use Select to project the results to a new collection of DateTime objects
Tuhin PaulPosted Apr 2, 2023, 1:50 PM
Use implicit typing (var) to improve readability
Rajkiran SwainPosted Apr 2, 2023, 12:00 PM
SessionDateproperty of theSessionclass is of typeDateTimeor a compatible type. Sorting may not work correctly if the property is not of a compatible type.SessionDateproperty are not null or uninitialized. If they are, you may need to filter out those sessions before sorting the list.ascendingkeyword to theorderbyclause to explicitly specify the sorting order:OrderByextension method instead of theorderbyclause:If none of these suggestions work, you may need to provide more information about the problem, such as the data types and values of the relevant properties, any error messages or exceptions, and the version of .NET you are using.