1
我想在我的EntitySetController從我的Get方法返回之前訂購的集合,這裏是我的代碼:返回從EntitySetController有序集合獲取
[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?)
我是否需要單獨的方法來返回有序集合?
謝謝!我只需將IOrderedEnumerable更改爲IOrderedQueryable即可運行 – user517406
是的,您是正確的。我犯了一個錯誤。 –