【发布时间】:2015-12-09 09:46:39
【问题描述】:
我有一个模型类,如下所示。
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 文件中抛出异常并出现错误。
【问题讨论】:
标签: c# sqlite windows-phone-8.1