I have a class Announcement, and I have a list of id, I am using the nuget package: sqlite-net-pcl. How can I delete an announcement from my Announcement table if I have it id. I am trynig to use linq like: await connection.DeleteAsync(announcement).Where(...) but I can't use Where with the DeleteAsync, so I tried
var query = connection.Table<Announcement>().Where(announcement=>announcement.AnnouncementId == announcementId)
it gives me this erro :System.NotSupportedException: Cannot delete AsyncTableQuery`1: it has no PK
I think you are looking for something like this:
public static int Delete(string url)
{
using (var databaseManager = DatabaseManager.Instance)
{
lock (databaseManager)
{
return databaseManager.Database.Table<File>().Delete(x => x.Url == url);
}
}
}
This is using SQLite;
https://developer.xamarin.com/guides/android/data-and-cloud-services/data-access/part-3-using-sqlite-orm/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With