1
我有一個如下所示的模型類。無法更新模型:它在Windows Phone 8.1中沒有PK c#
public class Section
{
[PrimaryKey]
public int section_id { get; set; }
public string name { get; set; }
public string url { get; set; }
public System.DateTime syncTime { get; set; }
}
當我嘗試更新我得到的錯誤消息無法更新章節:它沒有PK
下面是我的更新代碼
async public Task<bool> UpdateSection_SyncTime(int section_Id)
{
try
{
var sections = await db.Table<Section>().ToListAsync();
foreach (var section in sections)
{
if(section.section_id == section_Id)
{
section.syncTime = DateTime.Now; // Update the Section Sync Time
if (await db.UpdateAsync(section) >= 1)
return true;
}
}
}
catch { }
return false;
}
異常在SQLite.cs拋出文件與錯誤。
我應該使用非異步方法,而且我需要打開和關閉我的意思是首選的方法應該使用的連接。 – Sharath
我試過使用SQLiteConnection sqlConn = new SQLiteConnection(App.DBPath); sqlConn.Update(部);但仍然是同樣的問題。 – Sharath
有人可以幫我解決這個問題... – Sharath