Do I have to Close() a SQLConnection before it gets disposed?

Since you have a using block, the Dispose method of the SQLCommand will be called and it will close the connection: // System.Data.SqlClient.SqlConnection.Dispose disassemble protected override void Dispose(bool disposing) { if (disposing) { this._userConnectionOptions = null; this._poolGroup = null; this.Close(); } this.DisposeMe(disposing); base.Dispose(disposing); }

yield return statement inside a using() { } block Disposes before executing

When you call GetAllAnimals it doesn’t actually execute any code until you enumerate the returned IEnumerable in a foreach loop. The dataContext is being disposed as soon as the wrapper method returns, before you enumerate the IEnumerable. The simplest solution would be to make the wrapper method an iterator as well, like this: public static … Read more

Using Statement with Generics: using ISet = System.Collections.Generic.ISet

Unfortunately, the using directive does not do what you want. You can say: using Frob = System.String; and using ListOfInts = System.Collections.Generic.List<System.Int32>; but you cannot say using Blob<T> = System.Collections.Generic.List<T> or using Blob = System.Collections.Generic.List It’s a shortcoming of the language that has never been rectified.