I've created a generic search parameter class for reuse in several libraries (see below). I'm trying to find a better way to implement the list of values for each parameter. I will be passing a list of the parameters but inconsistent types for each parameter. I've implemented it as simply an object and will convert to the correct type as necessary in my code, but I feel like there is probably a better way to do this and I'm not coming up with much. Anyone done anything similar or have a suggestion? Thanks!
Generic Abstract Class:
public class SearchParameter<T>
{
public T Name { get; set; }
public List<object> Values { get; set; }
}
Inheriting Class:
public enum OrderSearchParameterNames
{
Barcode,
DateCompleted,
DatePlaced,
OrderStatus,
UserId
}
public class OrderSearchParameter : SearchParameter<OrderSearchParameterNames>
{
public OrderSearchParameter(OrderSearchParameterNames name, List<object> values)
{
Name = name;
Values = values;
}
}
Example of method using the inherited class:
public ApiResponse<OrderWellplate, ApiResponseStatus> SearchOrders(int currentPageIndex, int pageSize, List<OrderSearchParameter> searchParameters, OrderSortParameter sortParameter, out int recordCount)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire