Albert Newton

Albert Newton

  • NA
  • 6
  • 1.4k

How to check for empty GUID

Aug 21 2020 7:02 AM
I have in database a empty GUID.
 
But if I execute this code:
  1. List listOfOneResource = await _resourceService.GetResourcesById(new List { new Guid(welcome.WelcomePopupImage) });  
  2. Guid fileId = listOfOneResource.First().FileId ?? Guid.Empty; // this should never be empty in case of an image type resource  
  3. string fileIdString = fileId.ToString();  
  4. welcome.WelcomePopupImage = _appSettings.MedicalBaseUrl + "/resources/image/" + fileIdString + ".jpg";  
I get an error on this line:
  1. List listOfOneResource = await _resourceService.GetResourcesById(new List { new Guid(welcome.WelcomePopupImage) });
"message": "Unrecognized Guid format.", 
 
So what I have to change?

Answers (4)