Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带表的数据库。第一列是BusID单元格中的其余列是座位位置。1 代表可用座位,0 代表座位不能被占用(不可用)
BusID
用户输入座位位置,我把它放到一个变量中,然后我做了
var bus = db.Seats.Find(BusID); bus.seatPostion = 0; db.savechanges();
这给了我一个错误using a variable in the place of the column,知道如何解决这个问题吗?
using a variable in the place of the column
您必须使用总线项目的模型。假设您有总线的上下文模型:
public class Bus { public long BusID { get; set; } public long SeatPosition { get; set; } } var busId = your user input; Bus bus = db.Seats.Find(busId); if(bus != null) { bus.SeatPosition = 0; } db.saveChanges();