(sorry, I tried formatting it well, but I can't get the code formatting to work correctly)
I get:
Incorrect number of arguments supplied for call to method
'System.Linq.IQueryable`1[System.String]
Take[String](System.Linq.IQueryable`1[System.String], Int32)'
when i execute:
string[] companies = { "Consolidated Messenger", "Alpine Ski House", "Southridge Video", "City Power & Light",
"Coho Winery", "Wide World Importers", "Graphic Design Institute", "Adventure Works",
"Humongous Insurance", "Woodgrove Bank", "Margie Travel", "Northwind Traders",
"Blue Yonder Airlines", "Trey Research", "The Phone Company",
"Wingtip Toys", "Lucerne Publishing", "Fourth Coffee" };
IQueryable<String> queryableData = companies.AsQueryable<string>();
Expression e2 = Expression.Call(
typeof(Queryable).GetMethods().Where(m => m.Name == "Take")
.Single().MakeGenericMethod(new Type[] { typeof(string) }),
new Expression[] { Expression.Constant(4) });
IQueryable<string> res = queryableData.Provider.CreateQuery<string>(e2);
foreach (string s in res)
{
Console.WriteLine(s);
}
I think I need to pass the request object itself, but I can’t figure out how to do it (even if it is required).
Any help is appreciated.
Thanks.
source
share