我正在使用来自这里的 Entity Framework 审计追踪示例项目。
问题是,我们的项目已经在使用 .NET 4.0,但这个示例使用的是 .NET 4.5。
请问有人能告诉我在 .NET 4 中
在这段代码中:
问题是,我们的项目已经在使用 .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
无法识别。