I've begun playing a bit with implementing an IQueryable<T> datatype to query using LINQ. For example I've made a couple of functions like this (It is just a temporary detail that the extension method is not for the specific IQueryable implementation):
public static IQueryable<T> Pow<T>(this IQueryable<T> values, T pow)
{
var e = BinaryExpression.Power(values.Expression, ConstantExpression.Constant(pow));
return values.Provider.CreateQuery<T>(e);
}
Then I figured it would be useful to apply a function to each element in the IQueryable object but I can't quite figure out how to construct the proper expression. The method signature could look like this:
public static IQueryable<T> Map<T>(this IQueryable<T> values, Expression<Func<T,T>> map)
{
Expression e = ...
return values.Provider.CreateQuery<T>(e);
}
How should I complete this method body?