private static TValue GetEdmPropertyValue <TValue>(MetadataItem entitySet, string propertyName) { entitySet.AssertNotNull(nameof(entitySet)); if (entitySet.MetadataProperties.TryGetValue(propertyName, false, out var property)) { if (property?.Value is TValue str) { return(str); } } throw new Exception($"Unable to get '{typeof(TValue).Name}' value of EDM property '{propertyName}' of set '{entitySet}'"); }