接受此代码的语法:
public async Task UpdateLocationAsync(SOs_Locations locations)
{
var db = new SQLiteAsyncConnection(SQLitePath);
await db.UpdateAsync(locations);
}
...但我不知道SQLite引擎在简单地传递类实例时如何知道要更新哪条记录。是这样的情况,SQLite或SQLite-net引擎查看ID值,并在后台执行(在SQLese中):
UPDATE SOs_Locations
Set Bla = Bla, etc.
WHERE ID = locations.Id
答案 0 :(得分:3)
这正是它的作用。您可以查看方法here的来源:
var q = string.Format ("update \"{0}\" set {1} where {2} = ? ", map.TableName, string.Join (",", (from c in cols
select "\"" + c.Name + "\" = ? ").ToArray ()), pk.Name);
当然,如果您需要更多控制权,您可以随时执行自己的SQL:
db.ExecuteAsync("UPDATE SOs_Locations Set Bla = ?, WHERE ID = ?", bla, id);