public static Tuple <PropertyInfo, string> GetSortField <T>(this object obj, IDTO_Sort sortField) { Type type = typeof(T); PropertyInfo[] piArray = type.GetProperties(); return(piArray.GetSortField <T>(sortField)); }
public static Tuple <PropertyInfo, string> GetSortField <T>(this PropertyInfo[] piArray, IDTO_Sort sortField) { foreach (var pi in piArray) { var attr = pi.GetCustomAttribute <SortFieldAttribute>(); if (attr != null && attr.NickNames.Contains(sortField.FieldName, StringComparer.OrdinalIgnoreCase)) { return(new Tuple <PropertyInfo, string>(pi, attr.RealName)); } if (pi.Name.Equals(sortField.FieldName, StringComparison.OrdinalIgnoreCase)) { return(new Tuple <PropertyInfo, string>(pi, pi.Name)); } } return(null); }