Sqlite 如何检查xamarin中是否存在该记录
通常,如果项目已经有非零PK,那么它已经存在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
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);
}