例如,我有一个包含两列变量名和值的表。我需要为某些行编辑一个值单元格。我使用代码:
var stateVariable = from c in db.Table<StateVariables>() where c.VariableName == "cursor" select c;
stateVariable.First().Value = cursor;
stateVariable = from c in db.Table<StateVariables>() where c.VariableName == "cursor2" select c;
stateVariable.First().Value = cursor2;
stateVariable = from c in db.Table<StateVariables>() where c.VariableName == "isForward" select c;
stateVariable.First().Value = isForward;
此代码不会更改表中的值。看来我知道原因了。在这里,我正在尝试编辑提取的数据,而不是 db。那么,如何直接在 SQLite 表中编辑值呢?