在.NET 4.0中, GetCustomAttribute的等效方法是什么?

5
我正在使用来自这里的 Entity Framework 审计追踪示例项目。
问题是,我们的项目已经在使用 .NET 4.0,但这个示例使用的是 .NET 4.5。
请问有人能告诉我在 .NET 4 中 GetCustomAttribute 的等效方法是什么吗?下面是我的代码:
    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;
    }

在这段代码中:GetCustomAttribute无法识别。
1个回答

7

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接