lundi 27 juillet 2015

GetCustomAttribute Equivalent in .NET 4.0

I am using a sample project for Entity Framework Audit Trail from here

The problem is we are already using .NET 4.0 in our project but this sample is using .NET 4.5.

Can somebody tell me what is the equivalent of:

    private static string ColumnNameFactory(this Type type, string propertyName)
    {
        string columnName = propertyName;
        Type entityType = type.GetEntityType();
        var columnAttribute = entityType.GetProperty(propertyName).GetCustomAttribute<ColumnAttribute>(false);
        if (columnAttribute != null && !string.IsNullOrEmpty(columnAttribute.Name))
        {
            columnName = columnAttribute.Name;
        }
        return columnName;
    }

In this code: GetCustomAttribute is not recognized.





Aucun commentaire:

Enregistrer un commentaire