当前位置: 代码迷 >> ASP.NET >> linq 排名,该怎么解决
  详细解决方案

linq 排名,该怎么解决

热度:8565   发布时间:2013-02-25 00:00:00.0
linq 排名
数据访问用了 entity,数据库中有个player表 ,每个player 有个score,我想获得某个player的score的排名,该怎么写啊
 
  using (var data = new Entities1()) {
   
  Player player = data.Player.FirstOrDefault(d => d.Email_address == email);
   




------解决方案--------------------------------------------------------
oderby,排序。
------解决方案--------------------------------------------------------
using (var data = new Entities1()) {

var players = data.Player.orderby(p=>p.id);
int i=0;
foreach(var item idn players)
{
i++;
if(item.Email_address == email)
{
break;
}
}

}
------解决方案--------------------------------------------------------
var tr = from p in player
orderby score
select p;
  相关解决方案