5.6. "AutoConnection"-Behavior

In addition to programmatically demarcating a connection, you can allow the DaoManager to automatically Open and Close a connection for you. You don’t need to do anything special to use the autoconnection behavior, just don’t call OpenConnection().

Example 5.7. Example AutoConnection

[C#]
// Open/close first Connection
Product product = productDao.GetProduct (5); 
product.Description = "New description.";
// Open/close second Connection
productDao.UpdateProduct(product);
// Open/close third Connection
product = productDao.GetProduct (5);

[Note]Note

If the UpdateProduct() method contained more than a single update, you would need to use the BeginTransaction() method!