简体   繁体   中英

How can I update a SQLite record's attributes in C#?

I'm trying to update a SQLite record's boolean "Large" attribute in my code-behind. I'm using the sqlite-net-pcl Nuget package in Xamarin.Forms shared project.

I've figured out how to pass my record through to my method, but I can't get the attribute to update.

public async void PutBack(object sender, ItemTappedEventArgs e)
{
    var selectedListItem = e.Item as ListItem;
    selectedListItem.Large = false
    ...
}

When I run this I don't get any errors, but nothing happens. What's the correct syntax to update a record? It's weirdly hard to find documentation on this subject.

I assume you had create dependency in platform. So just open connection to SQLite according to your path. Like what you had to do when query it back. Like this,

var platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();   
var conn = new SQLiteConnection(platform, path);

then use that conn to run an update on that object after you edit.

conn.Update(selectedListItem);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM