I'm to the point now in my programming development that I'm trying to take advantage of Object Oriented Design instead of the basic behind the button procedural stuff I have been doing.
In a current project I'm taking repeated, copy and paste sql server insert code and migrating it to classes with properties, methods, etc...
One issue I'm getting stuck at is how to keep connections to the database low, while doing inserts across multiple objects, and therefore multiple tables.
In a procedural way I've been using an ADO.net transaction to write to one table, then based on the inserted record's ID, write additional information to another table -- without closing the connection until the second job is done. I use the transaction so if the later insert fails, the first insert can be undone, and using try, catch, finally to close the connection whether it succeeds or fails.
How do you handle this in the object oriented world?
EDIT: Thanks to everyone's answers. I get it. Here's another question that also helped to clarify it for me: http://stackoverflow.com/questions/334729/asp-net-ado-net-handling-many-database-connections-inside-a-net-object