You need to attach the object to the ObjectContext
. Try:
NEW_TABLE del = (NEW_TABLE)listView1.SelectedItems[0].Tag;
arama.Attach(del);
arama.DeleteObject(del);
arama.SaveChanges();
Attached objects are tracked by the ObjectContext
. This is needed for performing deletes and updates. You can read more about attaching objects on MSDN.
Edit to clarify attach/detach:
private void Form1_Load(object sender, EventArgs e) {
FirebirdEntity asa = new FirebirdEntity();
ObjectQuery<NEW_TABLE> sorgu = asa.NEW_TABLE;
foreach (var item in sorgu) {
asa.Detach(item);
// add to listView1
}
}
Also, you should wrap your use of ObjectContext
s in using
blocks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…