public static IList <T> Sort <T>(IList <T> records, string orderByString) { if (AllClientsOrderByType.IsValid(orderByString) || ClientOrderByType.IsValid(orderByString)) { return(records.AsQueryable().OrderBy(orderByString).ToList()); } throw new InvalidOperationException("Unknown AllClientsOrderByType Or ClientOrderByType QueryString"); }
public static AllClientsOrderByType Instantiate(string id) { AllClientsOrderByType reportType = null; foreach (AllClientsOrderByType knownReportType in knownTypes) { if (id == knownReportType.orderString) { reportType = knownReportType; break; } } if (reportType == null) { throw new InvalidOperationException("Unknown orderBy Query String"); } return(reportType); }
public static bool IsValid(string orderByString) { AllClientsOrderByType reportType = null; foreach (AllClientsOrderByType knownReportType in knownTypes) { if (orderByString == knownReportType.orderString) { reportType = knownReportType; break; } } if (reportType == null) { return(false); } return(true); }