public IEnumerable <RelationMetadata> GetRelationsMetaData(string logicalName, MetadataHelpers.RelationType type) { var key = $"MetaDataHelper.GetRelationMetaData|{logicalName}|{type}"; var cachedEntityMetaData = GetFromMemCache <IEnumerable <RelationMetadata> >(key); if (cachedEntityMetaData != null) { return(cachedEntityMetaData); } var retrievedMetaData = MetadataHelpers.GetEntityRelations(service, logicalName, type, CrmService.OrgId).ToList(); if (retrievedMetaData.Count <= 0) { throw new Exception($"Couldn't find metadata for relations of type '{type}' in entity '{logicalName}'."); } return(AddToMemCache(key, retrievedMetaData)); }