我刚开始使用mvc 4,并且在更新数据库时遇到问题。在我的数据库中,我有一个名为座位的表,其中有两列:seatnum和status。在下面我选择的状态与Seatss字符串(A1,A2等)中包含的座位号相匹配的席位,我想将状态更新为ID字符串的值,但不知道如何实现此状态。从ASP.NET MVC 4更新数据库
public JsonResult Checkout(string seatss, string ID)
{
var seats = from b in db.seats
select b;
seats = seats.Where(b => seats.Contains(b.seatnum));
foreach(var seat in seats)
{
//Perform status update on seats(This is the bit I can't figure out)
//$query="update seats set status='0' where seatnum="; (PDO query I want to implement)
}
return Json(seats, JsonRequestBehavior.AllowGet); // returns the selected seats as a json object.
}
我也想知道,这需要重构'席位= seats.Where(B => seats.Contains(b.seatnum));'使用'任何()'方法 – MethodMan 2014-12-01 20:41:02
是的,你的LINQ查询没有多大意义。 – abatishchev 2014-12-01 20:41:31
我完全不熟悉使用mvc 4和ef,所以我没有线索 – Jason 2014-12-01 20:45:34