ReSharper show warning with SqlDataReader
- by Belousov Pavel
When I write something like this:
using (var connection = new SqlConnection("ConnectionString"))
{
using(var cmd= new SqlCommand("Command"))
{
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
}
}
}
}
ReSharper shows warning on reader.Read(), and tells that reader can be null.
But in what cases can it be null? As I know if command returns nothing reader is not null, it only have nothing.