I have the following code in my application:
using (var database = new Database()) {
var poll = // Some database query code.
foreach (Question question
Look at the design for TransactionScope in System.Transactions. Their method requires you to call Complete() on the transaction scope to commit the transaction. I would consider designing your Database class to follow the same pattern:
using (var db = new Database())
{
... // Do some work
db.Commit();
}
You might want to introduce the concept of transactions outside of your Database object though. What happens if consumers want to use your class and do not want to use transactions and have everything auto commit?