U r already doing alot to achieve the thing,
(from n in Context.TBL_News.Take(5) orderedby n.NewsID descending select n).ToList();
So above line is converting it to a list, use a for loop to iterate through all list items and dont iterate for last row
i.e. the for loop should iterate items from 1 to 4 from the list
You can even use a new list to fill up with the first four elements of existing list
sadin
Member
69 Points
38 Posts
how to have 5 last record without last one ?
Mar 12, 2012 08:14 AM|LINK
i mean i want to get data from database with entity framework and linq query, i need last 5 record without last one.
for example i have 5 record in database i will write my query like this :
(from n in Context.TBL_News.Take(5) orderedby n.NewsID descending select n).ToList();
i dont want to display last on.
usman400
Contributor
3503 Points
721 Posts
Re: how to have 5 last record without last one ?
Mar 12, 2012 08:21 AM|LINK
U r already doing alot to achieve the thing,
(from n in Context.TBL_News.Take(5) orderedby n.NewsID descending select n).ToList();
So above line is converting it to a list, use a for loop to iterate through all list items and dont iterate for last row
i.e. the for loop should iterate items from 1 to 4 from the list
You can even use a new list to fill up with the first four elements of existing list