countrymeister
asked on
Filter a genric list T, with a string value
I Have a list T, would like to know if I could filter this list based on a stirng which has the filter criteria.
filter string = "Type = 'Shoes' AND Code = 'ABC' AND ProductGroup = 'InStock "
list T, T has properties
Type
Code
ProductGroup
filter string = "Type = 'Shoes' AND Code = 'ABC' AND ProductGroup = 'InStock "
list T, T has properties
Type
Code
ProductGroup
*No points*
I'd just add for informational purposes that p_davis' suggestion won't create new objects; it will just create a set of new references to the existing objects. This may or may not be a concern for your needs.
I'd just add for informational purposes that p_davis' suggestion won't create new objects; it will just create a set of new references to the existing objects. This may or may not be a concern for your needs.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
May I inquire: How are you building that filter string?
ASKER
kaufmed,
I have a pivot grid, and when the user selects a cell in the grid, I find the header of the column and the row header and build my string. in the cell click event.
I have a pivot grid, and when the user selects a cell in the grid, I find the header of the column and the row header and build my string. in the cell click event.
ASKER
I found my own solution
List<yourType> filteredList = yourList.FindAll(x=> x.Type == "Shoes" && x.Code == "ABC" && x.ProductGroup == "InStock");