c# - How to delete relational rows in WPF? -
i have 2 table (invoices-receipts), every invoice have more receipt (one many relation)
in wpf if want delete receipts specific invoice in 1 step, how can ?
i have tried this:
foreach (var item in _invoice.receipts) _invoice.receipts.remove(item);
but didn't work :(
thank in advance.
you can't delete item receipts
collection (is list<receipts>
?) while you're enumerating it. reason, code doesn't work.
create collection of items want remove in way:
var itemstoremove = new list<receipts>(); foreach (var item in _invoice.receipts) { if(condition) { itemstoremove.add(item); } }
and use removeall()
method remove them _invoice.receipts
:
_invoice.receipts.removeall(x => itemstoremove.contains(x));
Comments
Post a Comment