C# WIndows 8.1 WIndows应用商店应用程序sqlite更新语句

C# WIndows 8.1 WIndows应用商店应用程序sqlite更新语句,c#,sqlite,winrt-xaml,visual-studio-2013,windows-8.1,C#,Sqlite,Winrt Xaml,Visual Studio 2013,Windows 8.1,我无法使用“db.update”语句。当我尝试读取数据库时,它总是读取从else语句插入的第一个数据。我已经跟踪了我的程序,它确实到达了db.update,传递的值是正确的,但是当我读取表时,值没有改变 我正在使用Visual Studio 2013在windows 8.1中制作windows应用商店应用程序 这是我的密码 LastRead dataref = new LastRead { passID = U_pick.chapterID, chapterLastRead = U_pick.c

我无法使用“db.update”语句。当我尝试读取数据库时,它总是读取从else语句插入的第一个数据。我已经跟踪了我的程序,它确实到达了db.update,传递的值是正确的,但是当我读取表时,值没有改变

我正在使用Visual Studio 2013在windows 8.1中制作windows应用商店应用程序

这是我的密码

LastRead dataref = new LastRead { passID = U_pick.chapterID, chapterLastRead = U_pick.chapterNumber, passtitle = mTitle };
        var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Drive.db");
        using (var db = new SQLite.SQLiteConnection(dbpath))
        {
            try
            {
                var lastReadChapter = (db.Table<LastRead>().Where(c => c.passtitle == mTitle)).SingleOrDefault();
                if (lastReadChapter != null)
                {
                    lastReadChapter.chapterLastRead = U_pick.chapterNumber;
                    lastReadChapter.passtitle = U_pick.chapterTitle;
                    lastReadChapter.passID = U_pick.chapterID;
                    db.Update(lastReadChapter);
                }
                else
                {
                    db.Insert(dataref);
                }
            }
            catch(Exception ex)
            {
                //excepetion msg
            }


        }
LastRead dataref=new LastRead{passID=U_pick.chapterID,chapterread=U_pick.chapterNumber,passtitle=mTitle};
var dbpath=Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,“Drive.db”);
使用(var db=new SQLite.SQLiteConnection(dbpath))
{
尝试
{
var lastReadChapter=(db.Table().Where(c=>c.passtitle==mTitle)).SingleOrDefault();
如果(lastReadChapter!=null)
{
lastReadChapter.chapterLastRead=U_pick.chapterNumber;
lastReadChapter.passtitle=U_pick.chapterTitle;
lastReadChapter.passID=U_pick.chapterID;
数据库更新(最后一章);
}
其他的
{
db.插入(dataref);
}
}
捕获(例外情况除外)
{
//例外味精
}
}

这是因为您是通过SingleOrDefault()函数进行查询的