Hi Carterly,
Type.GetCustomAttributes will always return an object array, so in your LINQ statement, q is of type object. You will need to cast each one to QueryFieldAttribute to check it.
Luckily there is a Cast() method in LINQ to do it for you! So you can use:
Code:
IEnumerable<QueryFieldAttribute> queryFieldAttrs = QueryFields.Cast<QueryFieldAttribute>();
IEnumerable<QueryFieldAttribute> qfa = queryFieldAttrs.OrderBy(q => q.FriendlyFieldName);
Be careful tho, as this will error if the attribute isn't a QueryFieldAttribute or inherited from it. You can see in the QueryBuilder code that it checks if the attribute is a QueryFieldAttribute before using it.
You could of course get round this by extending ENTBaseQueryBO to create a second version of GetCustomAttributes() which takes an attribute type:
Code:
public object[] GetCustomAttributes(Type attributeType)
{
return typeof(T).GetCustomAttributes(attributeType, false);
}
Hope this gives you some ideas
Phil