I just grabbed the latest July 17th build and I am still seeing the following issue.
int[] ids = new int[] { 1, 2, 3, 4, 5};
LinqMetaData metaData = new LinqMetaData(DataAdapter);
var q = from c in metaData.Customers
select c;
var q2 = q.Where(c => c.Position == Array.IndexOf(ids, c.Id));
At q2, it seems the Array.IndexOf tries to get translated into SQL as "Customer.Position IS NULL." So no data gets returned.
I change it to a delegate, it does the filtering in memory.
var q2 = q.Where(delegate(Customer c) {
return c.Position == Array.IndexOf(ids, c.Id));
});
Another observation, if I call invoke the query before the filtering, as in call .ToList() before the Where, this forces the lambda to work in memory because the results are fetched already.
What is the proper way to do this? Should I be required to force the query before any in memory type operations? Is there any reason why the Array.IndexOf method isn't be picked up to work in memory and not in sql?