【发布时间】:2014-03-30 17:54:03
【问题描述】:
我试图在从我的 EntitySetController 中的 Get 方法返回之前订购一个集合,这是我的代码:
[Queryable]
public IQueryable<Standing> GetStandings()
{
//order by points, goalsfor-goalsagainst, goalsfor, teamname
IQueryable<Standing> standings = db.Standings.Include("Team").Include("Stage");
var standingsQuery = from s in standings
let points = (s.Won*3) + (s.Drawn*1)
select standings.OrderByDescending(p => points)
.ThenByDescending(g => g.GoalsFor - g.GoalsAgainst)
.ThenBy(t => t.Team.TeamName);
return standingsQuery.AsQueryable();
}
但我得到了错误:
Cannot implicitly convert type 'System.Linq.IQueryable<System.Linq.IOrderedQueryable<Standing>>' to 'System.Linq.IQueryable<Standing>'. An explicit conversion exists (are you missing a cast?)
我需要一个单独的方法来返回一个有序的集合吗?
【问题讨论】:
标签: asp.net-mvc asp.net-web-api odata