我的视图页面未显示数据库中的真实值。
我在模型类中有这些行:
public static db_XXXXXXx db = new db_XXXXXX();
public IEnumerable<Booking> Bookings = db.Bookings.SqlQuery("SELECT * FROM [dbo].[Bookings] WHERE RoomId IS NULL");
在我的控制器中是:
public ActionResult Index()
{
var bookings = new List<Booking>();
for (int i = 0; i < 10; i++)
{
bookings.Add(new Booking());
}
var model = new ClerkBookingViewModel
{
Bookings = bookings
};
return View(model);
}
如果我从SQL Server Management Studio直接在db上运行相同的查询 - 返回1行,并且没有值为0但我的网页显示为意外,因为值不是0.
预订ID 0 Bunks Required 0