I have this method that I want to write:
public static IQueryable<TSource> CutTo<TSource>(this IQueryable<TSource> source, Func<int> func)
{
int index = func();
// here I can write something for all types or switch all
// the types and write code for every type
}
What is the easiest way to code this for all TSource types?
Edit: Black Bear writes that this already works for all types but this is not true. Mono writes like this:
public static IQueryable<TSource> Where<TSource> (this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
{
Check.SourceAndPredicate (source, predicate);
return source.Provider.CreateQuery<TSource> (
StaticCall (
MakeGeneric (MethodBase.GetCurrentMethod (), typeof (TSource)),
source.Expression,
Expression.Quote (predicate)));
}