Do I need to close a SqlDataReader before I call D

2019-04-14 18:02发布

问题:

According to this, Dispose() on a SqlConnection calls Close(), so you don't need to call both, just Dispose(). Is it the same for a SqlDataReader?

回答1:

You only need to call Dispose because calls Close.

I used .NET Reflector and found that DbDataReader's (the base of SqlDataReader) Dispose method does call Close.