I expected the following LINQ query to sort according to FirstName but the OrderBy extension method seems to have no effect.
DataClassesDataContext dc = new DataClassesDataContext(); var query = from contact in dc.Contacts select contact; query.OrderBy(c => c.FirstName);
Everything works fine when I include the orderby in the initial query definition but I want to be able to modify it based on conditions later in my code.
Any idea why this isn’t working?
try using
or
The OrderBy creates a new sequence.