I have a database table containing the news on my site. It’s divided into to group – team and board. I connect using LINQ.
The team news are being shown on all pages and the board news are being shown only on the front page.
I have tried this, because i want the 5 newest entires about team to be shown:
var query = from esh in gr.nyheders
where esh.typeBeskrivelse.Equals("team") && esh.id > ((from es in gr.nyheders where esh.typeBeskrivelse.Equals("team") select es.id).Max() - 5)
orderby esh.dato descending
select esh;
But it only shows two, since the 2 team news have ID <= 5.
how do I select the 5 newest team posts??
There is a
Takemethod, that can be given a number of records to return. Take a look at http://msdn.microsoft.com/de-de/library/bb503062.aspx for more information