private void gv_RowDeleting(object sender, DevExpress.Data.RowDeletingEventArgs e) { try { filen ct = (from c in dbData.filens select c).Single(x => x.key == gv.GetFocusedRowCellValue("key").ToString()); dbData.filens.DeleteOnSubmit(ct); } catch { } }
public void xoa(string key) { using (var trans = new TransactionScope()) { dbData = new KetNoiDBDataContext(); nhansu ns = (from a in dbData.nhansus select a).Single(t => t.key == key); dbData.nhansus.DeleteOnSubmit(ns); var f = (from a in dbData.filens where a.keyns == key select a); foreach (var fa in f) { filen file = fa; dbData.filens.DeleteOnSubmit(fa); } dbData.SubmitChanges(); trans.Complete(); } }