c# - How to use Orderby Clause with IEnumerable -


i have written following code:

ienumerable<models.bookings> search = new list<bookings>(); search = new available_slotsrepositories().getavailableslot(param1,param2);        var data = s in search.asenumerable().            orderbydescending(c => c.bookingdate)            select s; 

i have tried , not work:

search.orderbydescending(c => c.bookingdate); 

third line gives me following error: expression cannot contain lambda expressions

any 1 guide me how can fix issue?

any appreciated.

thank you!

why r u using new list()??

follow below pattern

ienumerable<step> steps = allsteps.where(step => step.x <= y);  steps = steps.orderby(step => step.x); 

note:

ienumerable makes no guarantees ordering, implementations use ienumerable may or may not guarantee ordering.

for instance, if enumerate list, order guaranteed, if enumerate hashset no such guarantee provided, yet both enumerated using ienumerable interface

perhaps looking iorderedenumerable interface? returned extensions methods orderby() , allow subsequent sorting thenby().


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -