Warning: NULL literal or a possible NULL value is being converted to a non-nullable type.

Ladies and gentlemen,

I am confronted with a new type of warning, that I would like to understand.

What should I do?

This is the code:

    [HttpGet("/{userSlug}")]
    public async Task<User> ShowUser(string userSlug)
    {
        User user = await _dataContext.Users.FirstOrDefaultAsync((u) => u.Slug == userSlug);

        return user;
    }


This is the message:

NULL literal or a possible NULL value is being converted to a non-nullable type
Was this page helpful?