Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save samueleresca/b9e25bcc2763403ee6b6 to your computer and use it in GitHub Desktop.
Save samueleresca/b9e25bcc2763403ee6b6 to your computer and use it in GitHub Desktop.
public static IQueryable Take(this IQueryable source, int count)
{
if (source == null)
throw Error.ArgumentNull("source");
return source.Provider.CreateQuery(
Expression.Call(
null,
((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
new Expression[] { source.Expression, Expression.Constant(count) }
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment