ReSharper show warning with SqlDataReader
Posted
by Belousov Pavel
on Stack Overflow
See other posts from Stack Overflow
or by Belousov Pavel
Published on 2010-06-14T07:28:53Z
Indexed on
2010/06/14
7:32 UTC
Read the original article
Hit count: 192
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.
© Stack Overflow or respective owner