我正在尝试更新记录,但不起作用。我已经宣布活动为bool,并且在数据库中它是位。
enter code here
string str = DateTime.Now.ToShortTimeString();
var update = db.Logs.Single(u => u.id == id);
update.logout = str;
update.active = false;
答案 0 :(得分:1)
尝试一下
string str = DateTime.Now.ToShortTimeString();
List<Single> results = (from s in in Logs.Single
where s.id == id
select s).ToList();
foreach (Single s in results)
{
s.logout = str;
s.active = false;
}
答案 1 :(得分:0)
请尝试这个。
db.Logs.Where(x => x.id == id).ToList().ForEach(x =>
{
x.logout = str;
x.active = false;
});