我尝试在 Visual Studio 2012 中使用 SQLite/C# 从数据库中删除记录。每当我尝试删除记录时,都会收到以下错误:
SQLite 错误:无法删除WhereListIterator`1:它没有 PK
我想使用两种不同的方法删除记录。仅使用主键 EID 进行删除,或者删除用户提供除 EID 之外的所有内容的记录。
if (EID_TextBox.Text != String.Empty) {
if (Roster_Enrollment.Any(x => x.EID.Equals(Int32.Parse(EID_TextBox.Text)))) {
App.DBConnection.Delete(Roster_Enrollment.Where(x => x.EID.Equals(Int32.Parse(EID_TextBox.Text))));
Message_TextBlock.Text = "Enrollment deleted.";
} else
Message_TextBlock.Text = "Enrollment not found.";
}
else if (Roster_Enrollment.Any(x => x.CourseNo.Equals(CourseNo_TextBox.Text) && x.SectionNo.Equals(SectionNo_TextBox.Text) && x.Tno.Equals(Tno_TextBox.Text)))
App.DBConnection.Delete(Roster_Enrollment.Where(x => x.CourseNo.Equals(CourseNo_TextBox.Text) && x.SectionNo.Equals(SectionNo_TextBox.Text) && x.Tno.Equals(Tno_TextBox.Text)));
else
Message_TextBlock.Text = "Enrollment not found.";
你的类数据模型有Table
属性和PrimaryKey
属性?
[Table("StuffDataModel")]
public class StuffDataModel
{
[PrimaryKey]
public int Id { get; set; }
public byte[] Stuff { get; set; }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)