Metadata were not loaded using MetadataType

because metadatatype is not for such porposes but you can use this method

private bool PropertyHasAttribute<T>(string properyName, Type attributeType)
    {
        MetadataTypeAttribute att = (MetadataTypeAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(MetadataTypeAttribute));
        if (att != null)
        {
            ;
            foreach (var prop in Type.GetType(att.MetadataClassType.UnderlyingSystemType.FullName).GetProperties())
            {
                if (properyName.ToLower() == prop.Name.ToLower() && Attribute.IsDefined(prop,attributeType))
                    return true;
            }
        }
        return false;
    }

and you can use like this

bool res = PropertyHasAttribute<ClientInfoView>("Login", typeof(DisplayAttribute))

this tell you that the class property login has or has not displayattribute , but if you need to findout attribute Value you can use Attribute.GetCustomAttribute method and cast it to your selected attribute like display attribute and read Name property by .Name 🙂

Leave a Comment