我正在过滤PropertyInfo这样的列表:
foreach (PropertyInfo propertyInfo in 
            ClassUtils.GetProperties(patternType).
            Where(pi => pi.GetCustomAttribute<TemplateParamAttribute>() != null).
            OrderBy(pi1 => pi1.GetCustomAttribute<TemplateParamAttribute>().Order))
{
    TemplateParamAttribute attr = propertyInfo.GetCustomAttribute<TemplateParamAttribute>();
...
这可以正常工作,但我对GetCustomAttribute每次迭代中的 3 次调用并不满意。有没有办法减少GetCustomAttribute调用次数(并且仍然使用 linq)?