0

I have a an array, that has data, howeever when I want to filter that array using linq Where, I am getting exception Object reference not set to an instance of an object.

so What I have

var images = await _repository.DeleteMerchantProductAsync(baseProductId, userId);

now I f I do images.count I get 1

However when I do images[0] it return null.

if (!images.Any())
{
    return false;
}
var paths = images
    .Where(i => !string.IsNullOrWhiteSpace(i.FileName))
    .Select(i => i.FileName)
    .ToList();

it throws exception at

var paths = images
    .Where(i => !string.IsNullOrWhiteSpace(i.FileName))
    .Select(i => i.FileName)
    .ToList();

Any reason ?

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
user123456
  • 2,524
  • 7
  • 30
  • 57

0 Answers0