I want to test if my byte[] element ImageData contains any data. If there is no data my database shows it as NULL. I tried using the .Any() method, but for some reason this does not work. Why?
I have tried it with the following code
public FileStreamResult ViewImage(int id)
{
    Candidate candidate = _context.Candidate.FirstOrDefault(m => m.Id == id);
    bool hasImage = candidate.ImageData.Any();  // I get the NullException here          
    if (hasImage)
    {
        MemoryStream ms = new MemoryStream(candidate.ImageData);
        return new FileStreamResult(ms, candidate.ImageType);
    }
    return null;            
}
If I use the logic  if(candidate.ImageData == null), I get a true or false. I considered using Any() more elegant. Any suggestions?
 
     
     
     
    