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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -