Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sqlite 如何检查xamarin中是否存在该记录_Sqlite - Fatal编程技术网

Sqlite 如何检查xamarin中是否存在该记录

Sqlite 如何检查xamarin中是否存在该记录,sqlite,Sqlite,通常,如果项目已经有非零PK,那么它已经存在 public bool insertIntoTablePerson(Person person) { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db"))) { connection.Insert(person); return true; } } ca

通常,如果项目已经有非零PK,那么它已经存在

public bool insertIntoTablePerson(Person person)
{
  try
  {
    using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db")))
    {
      connection.Insert(person);
      return true;
    }
  } catch (SQLiteException ex) {
    Log.Info("SQLiteEx", ex.Message);
    return false;
  }
}

public bool insertIntoTablePersonPerson{try{using var connection=new SQLiteConnectionSystem.IO.Path.Combinefolder,Persons.db{connection.Insertperson;返回true;}catch SQLiteException ex{Log.InfoSQLiteEx,ex.Message;return false;}}您应该查询数据库并使用此人的id检查此人是否存在。
  if (item.ID != 0)
  {
    return database.UpdateAsync(item);
  }
  else {
    return database.InsertAsync(item);
  }