Ean

Ean

  • NA
  • 1
  • 0

Updating a DB with a List of business Objects similar to TableAdpater.Update()

Jun 26 2010 4:22 AM


I have a problem which I thought would have been generally run-of-the-mill but I can't seem to find an answer anywhere,
I wish to send updates to a BindingList<Type> back to the database, in a similar way that the TableAdapter.Update() works.

This is the scenario:
My Contact object contains a List of Address objects.

I have no problem with retrieveing the addresses from the database and then populating my BindingList<Address> with the addresses.  This can then be bound to a datagrid view on the form in my presentation layer.

But my question is how do I reverse this process ie: how do I pass a BindingList<Address> back to my business layer and have that update the database with all of the changes - something like TableAdatper.Update which will Insert, Delete or Update as appropriate for each item in a datatable.

Any help would be much appreciated - I'm really trying to build my app with a good business layer using business objects but this single unknown piece of the puzzle is hampering my efforts and frustrating me to no end!.

Thanks for any help!