diff --git a/src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs b/src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs index b4175a34f..6622cd49d 100644 --- a/src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs +++ b/src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs @@ -182,7 +182,7 @@ private ReferencedResourceCache getOrInitContainedCache() if (AtResource) { var referenceEntryPairs = from contained in this.Children("contained") - let id = $"#{contained.Children("id").FirstOrDefault()?.Value as string}" + let id = contained.Children("id").FirstOrDefault()?.Value is string s ? $"#{s}" : null let resource = contained as ScopedNode select new KeyValuePair(id, resource); _cache.ContainedResources = new ReferencedResourceCache(referenceEntryPairs);