Henrique Albuquerque
Henrique Albuquerque

Reputation: 45

How to Execute UpdateAsync with Where statement

I have a table with 1 row. log => 1 | flagLog => 0

 public async void updateFlag()
    {
        var local = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "hinos.sqlite");
        SQLiteAsyncConnection con = new SQLiteAsyncConnection(local, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite);

        var updateFlagLog = await con.FindAsync<logon>(u => u.log == 1);
        if (updateFlagLog != null)
        {
             await con.UpdateAsync(?????);
        // update logon set flagLog = 1 where log = 1;

        }
    }

I got the row with this comand

var updateFlagLog = await con.FindAsync<logon>(u => u.log == 1);

But i dont know how i use to update this row.

Upvotes: 2

Views: 666

Answers (1)

Francesc Castells
Francesc Castells

Reputation: 2847

I believe you only have to pass the object you want to update.

    var updateFlagLog = await con.FindAsync<logon>(u => u.log == 1);
    if (updateFlagLog != null)
    {
         // TODO do the changes you need to updateFlagLog

         // Update the object
         await con.UpdateAsync(updateFlagLog);
    }

Upvotes: 1

Related Questions