I am trying to migrate an old project to using LINQ but I have run into a pretty major problem. The problem is we have dynamic tables for search indexing (CM-system with dynamic attributes). The search index has columns for each searchable attribute { attribute_x, attribute_y, ... }. Now the problem is I cannot statically define which columns are available (or even which table to use as we divide search indexes), so I need a way to do this on the fly.
I have tried using Dynamic Expressions, but they still require a type to build the expression from, and I haven't been able to generate a valid type by reflection. (It seems no MemberInfo is generated).
I could also satisfy with just being able to generate an expression for searching ( but I guess this is no easier task ). Something along the lines of
var mySearchIndex= db.GetTable(myTableType); var query = from p in db.Products from idx in mySearchIndex; query = query.Where( "idx." + attributeName + " > 50.0 && idx." + attributeName + "
would be desirable.
Has anyone come across a solution to this problem? I have been looking through blog posts and forums for the past two days in vain.