Possible Null assignment to non-nullable entity
Completed
I've a strange warning on the following block of code :
public static int FooBar(object content)
{
var contentType = _db.Model.FindEntityType(content.GetType());
if (contentType?.GetTableName() == null) return 0;
var storeObjectIdentifier = StoreObjectIdentifier.Table(contentType.GetTableName(), contentType.GetSchema());
return 0;
}
If I understand well the warning, he complaints because the first parameter does not allow null
(public static StoreObjectIdentifier Table(string name, string? schema = null)
But if its null I've already left the block, no ?
Thanks
Please sign in to leave a comment.
I suspect R# can't be certain that calling the same method twice will return the same value. Try storing the value returned from GetTableName in a local variable instead.
It makes sense, thank you.