Best approch to dynamically filter .net objects
- by maxba
The project i´m working currently on has a way to define a filter to filter objects from a database.
This filter is a pretty straitforward class containing filtercriteria that will be combined to a sql where-clause.
The goal now is to use this filter class to filter .net objects as well. So the filter for example defines, that the title property of the object that it is applied to must contain some userdefined string etc.
What are ways to approch this problem? What should the filter return instead of the sql where-clause and how can it be applied to the object? I´m thinking about this for hours and don´t yet have even a slight idea how to solve this. Been thinking about reflection, dynamic code execution, building expressions but still haven´t found an acutal starting point.