I want to reverse the output of a LINQ to SQL query.
and .Reverse() does not work, just crashes the page.
protected void Page_Load(object sender, EventArgs e)
{
NewsDataContext db = new NewsDataContext();
var News = from news in db.News
select new
{
ID = news.NewsID,
kort = news.Short
};
foreach (var newa in News)
{
Panel1.
Controls.
Add(new LiteralControl(newa.kort +
"</br>" +
"<a href=Full.aspx?id=" +
newa.ID +
">Read The full Article</a>"));
}
}
Is there another way to reverse it?
I’m guessing SQL Server doesn’t know how to translate Reverse into a T-SQL command, so you’re getting an exception. You’ll probably need to pull the results of the query down from the database, then reverse it.