I\'ve always used using with variable and assignment. Now i have like this a class DbProviderConnection:
public class DbProviderConnection : IDisposable
{
Yeah, the Dispose will be called. the using
statement only works with disposable objects. Like this:
using (DbProviderConnection cnctn = _planDb.CreateOpenConnection())
{
using (cnctn.BeginTransaction())
{
// ...
cnctn.Transaction.Commit();
} // Here BeginTransaction.Dispose() is called.
} // Here DbProviderConnection.Dispose() is called.