I have an array of properties (System.Reflection.PropertyInfo[8]
). Each of these properties have a custom attribute set on them. I want to group them all by which custom attribute they have and am trying to use reflection to do this. So far I have tried:
var searchableProperties = properties.GroupBy(a => a.GetCustomAttribute(typeof(IsSearchableAttribute)));
var filterableProperties = properties.GroupBy(a => a.GetCustomAttribute(typeof(IsFilterableAttribute)));
However these are coming back as null rather than grouping by attributes.
Can anyone point out to me where I am going wrong here? Thanks
Aucun commentaire:
Enregistrer un commentaire