我遇到了一個問題,我的列表框無法更新數據。我有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