If I write the following code, ReSharper is warning me for a possible NullReferenceException
. However I'm explicitly checking for null
in the statement above. Is there something about dynamic
I do not know about (is it assuming it might be backed by a IEnumerable
or something like that)? Or is this a glitch with ReSharper? Or something else?
dynamic user = connection.Query("SELECT ...").FirstOrDefault(); // Dapper Extension
if (user == null)
return null;
return new User(user.username);
// ^^^^
// (local variable) dynamic user
//
// Possible 'System.NullReferenceException'