我正在使用Xamarin表单,我使用Sqlite-net-pcl nuget包实现了SQLite数据库。问题是数据库最初保存了一行但无法更新或删除任何行。这是我使用Key保存和删除数据库行的代码。
public Task<int> SaveItemAsync(SQLiteRowData item)
{
if (item.ID != 0)
{
return database.UpdateAsync(item);
}
else
{
return database.InsertAsync(item);
}
}
public Task<int> DeleteItemAsync(SQLiteRowData item)
{
return database.DeleteAsync(item);
}
public Task<int> DeleteItemAsyncWithKey(string key)
{
Task<SQLite.SQLiteRowData> lSQLiteRowTaskData =
App.sqliteConnectionPath.GetItemForKeyAsync(key);
SQLite.SQLiteRowData lSQLiteRowData = lSQLiteRowTaskData.Result;
return database.DeleteAsync(lSQLiteRowData);
}
public async Task<bool> DeleteUserPreferencesAsync()
{
Boolean lReturnValue = false;
try
{
Task<SQLiteRowData> lSQLiteRowDataTask = App.sqliteConnectionPath.GetItemForKeyAsync("UserPreferences"); SQLiteRowData lSQLiteRowData = lSQLiteRowDataTask.Result;
if (lSQLiteRowData != null) {
await DeleteItemAsync(lSQLiteRowData);
lReturnValue = true;
}
}
catch (Exception ex)
{
EMAUtilities.printLogs(ex.Message);
}
return lReturnValue;
}
// Used for saving userpreference
SQLiteRowData lSQLiteRowData = new SQLiteRowData("UserPreferences", lValue);
Task<int> x = SaveItemAsync(lSQLiteRowData);
任何人都可以指出我在此做过的错误,提前谢谢