c# - Convert Sql query to linq contains conditional OrderBy / ThenBy clause -
tablea
contains list of recent items user has accessed, user has option pin/remove list.
what trying list has order below query.
select * tablea order ispinned desc, case when ispinned = 1 date end asc, case when ispinned = 0 date end desc
but in linq fails. have tried below.
_lst = _lst.orderbydescending( x => x.ispinned).thenbydescending(x=>x.accessdate).tolist();
.
_lst = (from data in _lst orderby data.ispinned, data.ispinned ? data.date : data.date descending select data ).tolist();
try:
_lst = _lst.orderbydescending(x => x.ispinned) .thenby(x=> x.ispinned ? x.accessdate.ticks : x.accessdate.ticks * -1 ) .tolist();
Comments
Post a Comment