首页 > 代码库 > asp.net LINQ数据访问技术from where select order by子句

asp.net LINQ数据访问技术from where select order by子句


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int[] values = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
var value = http://www.mamicode.com/from v in values
where v < 3 || v > 7
orderby v descending
select v;
Response.Write("查询结果:<br>");
foreach (var i in value)
{
Response.Write(i + "<br>");
}
}
}

 

技术分享

在LINO查询表达式中,orderby 升序用ascending关键字,降序用descending关键字

 

asp.net LINQ数据访问技术from where select order by子句