0
我想對數據庫表進行排序並將結果顯示在MVC中的視圖中。 控制器中的查詢返回控制檯應用程序(引用相同數據庫)中的排序結果,但列表在視圖中顯示爲未排序。我做錯了什麼/失蹤?未在視圖中顯示MVC控制器查詢結果
public class HomeController : Controller
{
private SwimTimesEntities db = new SwimTimesEntities();
public ActionResult Index()
{
var query = from s in db.Swims
orderby s.Day
select s;
return View(query.ToList());
}
和模型是
public partial class Swim
{
public int SwimID { get; set; }
public System.TimeSpan Time { get; set; }
public string Day { get; set; }
public string Details { get; set; }
}
}
(非常)新的C#和MVC,指針讚賞。
謝謝。這是工作。 –