private static Type GetAssociatedMetadataType(Type type)
        {
            Type associatedMetadataType = null;

            // try association attribute
            MetadataTypeAttribute attribute = (MetadataTypeAttribute)Attribute.GetCustomAttribute(type, typeof(MetadataTypeAttribute));

            if (attribute != null)
            {
                associatedMetadataType = attribute.MetadataClassType;
            }

            return(associatedMetadataType);
        }
            public static Type GetAssociatedMetadataType(Type type)
            {
                Type associatedMetadataType = null;

                if (_metadataTypeCache.TryGetValue(type, out associatedMetadataType))
                {
                    return(associatedMetadataType);
                }

                // Try association attribute
                MetadataTypeAttribute attribute = (MetadataTypeAttribute)Attribute.GetCustomAttribute(type, typeof(MetadataTypeAttribute));

                if (attribute != null)
                {
                    associatedMetadataType = attribute.MetadataClassType;
                }
                _metadataTypeCache.TryAdd(type, associatedMetadataType);
                return(associatedMetadataType);
            }