我遇到了一个问题,我的列表框无法更新数据。我有2个桌子,时间和trolleyservice。该列表框读取并显示来自时序表的数据。两个表都被链接了。每当我更新了手推车服务表的时候,它提示我这个错误:使用列表框更新数据库
The property 'TimingID' is part of the object's key information and cannot be modified.
谁能帮助这个吗?
private void btnUpdateTS_Click(object sender, EventArgs e)
{
int ID = Int32.Parse(lblID.Text);
foreach (timing selectedTiming in lstTime.SelectedItems)
{
var EditTS = (from ets in db.trolleyservices
where ets.idtrolleyservice == ID
select ets).First();
EditTS.Type = txtType.Text;
EditTS.TimingID = selectedTiming.TimingID;
db.SaveChanges();
txtType.Text = "";
}
}
这个实体框架? – Prasanna
是的这是实体框架 – Philemon