Next and Previous Links Using Linq to SQL
I need to add "Next" and "Previous" links to a webpage that displays posts in date order. The SQL table contains the message number, subject and date. I am currently using a stored procedure that uses the ROW_NUMBER function:
with MessageList AS ( select msg_num, row_number () over (order by msg_date) as rownum from tblHeaders) SELECT nextrow.msg_num AS NextMsg FROM MessageList currow LEFT JOIN MessageList nextrow ON currow.rownum = nextrow.rownum - 1 LEFT JOIN MessageList prevrow ON currow.rownum = prevrow.rownum + 1 where currow.msg_num = @msgnum
Using Linq to SQL, how would I create links to the "Next" and "Previous" numbers given the current post number and where is the table sorted in order date?
0
mgm
source
to share