Ordering LinQ c# -


im trying order linq date value showing first today's date , counting down in actual linq values not arranged come ordered day , month never today's date

this linq:

foreach (var item in db.venta_platillos.select(l => l.fecha)          .distinct().orderbydescending(x => x.month == result.month && x.day == result.day)) {     dateday = item.tostring("yyyy-mm-dd");     var listitem = new selectlistitem { value = dateday, text = dateday };     listitem.selected = result.day == item.day;     listdate.add(listitem); } 

how can order them correctly actual date first?

edit********

values comes datetime model variable wil add examples of dates:

2016-11-06 00:00:00.000 2016-11-05 00:00:00.000 2016-11-04 00:00:00.000 2016-11-03 00:00:00.000 2016-11-02 00:00:00.000 2016-10-31 00:00:00.000 2016-10-29 00:00:00.000 

like this

edit 2 *****

got fixed ordering month , day worked after making changes model

        .orderbydescending(x => x.month)         .thenbydescending(x => x.day) 

linq offers thenbydescending allow order after initial order.

but should able this

.orderbydescending(x => x) because you're iterating on datetime.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -