I am using reflection along with linq.Dynamic, and I am having a small problem with creating a query that needs to get IQueryable<T>
from an IList<T>
or ISet<T>
when I currently have an object.
At first I thought I could write a little helper method:
object Helper<T>( IList<T> list, string query, param object[] values )
{
... do query and return result.
}
Unfortunately the compiler needs to infer the T argument which it cannot do when passed an object.
Is there a simple way to get around this? I am trying to avoid dynamically invoking this helper function as well.
EDIT: I have a Domain object that currently as several IList collections I am trying to query against this class to find the proper object to display on the screen. Basically I have a screen guid 10 and a xpathish string "FruitBasket/Fruit[Ripe == true]/color" So I know Fruit is an IList in my reflection code I inspect the property to find out if it implements IList now I am at the point where i need to query this collection to pick out the Fruit.Ripe == true objects. For this I need a cast to IQuerable