I have a list with objects Article. Parameters for this object:
Category, Description, Status, Class
The user can filter the list using the combination that he wants. Only description, or Category + Class, and so on.
So, if the user selects the criteria, I will get int> = 0, otherwise I will get -1.
For example, if he selects a filter with Statusand Category, I get
FilterCategory = x, FilterDescription = -1, FilterStatus = y, Filterclass = -1
My way to filter the list is as follows:
if (FilterCategory != -1)
list = list.Where(a => a.Category == FilterCategory);
if (FilterDescription != -1)
list = list.Where(a => a.Description == FilterDescription);
if (FilterStatus != -1)
list = list.Where(a => a.Status == FilterStatus);
if (FilterClass != -1)
list = list.Where(a => a.Class == FilterClass);
, 4 , . 4 . , != -1.