I am trying to migrate an old project to LINQ, but I ran into a pretty serious problem. The problem is that we have dynamic tables for indexing the search (CM system with dynamic attributes). The search index contains columns for each search attribute {attribute_x, attribute_y, ...}. Now the problem is that I cannot statically determine which columns are available (or even which table to use when dividing the search indexes), so I need a way to do this on the fly.
I tried using dynamic expressions, but they still need a type to create the expression, and I could not create the correct type by reflection. (It seems MemberInfo is not generated).
I could also satisfy just by being able to generate an expression to search for (but I think this is not an easy task). Something along the lines
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.
Can anyone find a solution to this problem? I watched blogs and forums for the last two days in vain.
runeborg
source share