Best approch to dynamically filter .net objects

Posted by maxba on Stack Overflow See other posts from Stack Overflow or by maxba
Published on 2011-01-09T10:35:58Z Indexed on 2011/01/09 10:53 UTC
Read the original article Hit count: 234

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about design

Related posts about dynamic