Aaah, I see what you are asking... And you're really entering some very murky waters, one of the few areas that the .NET reflection libraries aren't beautiful to work with. You have to create a call expression to call Queryable.Where() on the queryableData object, and create a new query using that expression... The problem is that getting a generic version of a method in .NET isn't necessarily the easiest thing you've ever run across in your life:
MethodCallExpression call = Expression.Call(
null, // Calling Queryable.Where(), extension method, not instance method
getGenericMethod<string>(typeof(Queryable), "Where", typeof(IQueryable<string>), typeof(Expression<Func<string,bool>>)),
Expression.Constant(queryableData),
Expression.Lamda(
e1,
p1)
);
IQueryable<string> res = queryableData.Provider.CreateQuery<string>(call);
You would also have to define getGenericMethod (you can find better implementations for this online at other places, this is really quite a simple approach):
private static MethodInfo getGenericMethod<T>(Type type, string name, params Type[] paramTypes)
{
MethodInfo[] methods = type.GetMethods(name);
foreach(MethodInfo mi in methods)
{
if(!mi.IsGenericMethodDefinition) // or some similar property
continue;
if(mi.GetGenericArguments().Length != 1)
continue;
if(mi.GetParameters().Length != paramTypes.Length)
continue;
MethodInfo genMethod = mi.MakeGenericMethod(new Type[]{typeof(T)});
var ps = genMethod.GetParameters();
bool isGood = true;
for(int i = 0; i < ps.Length; i++)
{
if(ps[i].ParameterType != paramTypes[i])
{
isGood = false;
break;
}
}
if(isGood)
return genMethod;
}
return null;
}
There are almost undoubtedly a few errors in there, but I hope you can see where to go from there...