For some reason, my call to IEnumerable.Where() using String.StartsWith() appears to be giving different results depending on whether it\'s being used in LINQ-to-SQL or stan
In the first case, indeed the Where
predicate doesn't need to be translatable to SQL, since you are first getting the whole table to memory (ToList
) and then doing the filtering.
In the second case, the Where
predicate needs to be translatable to a SQL WHERE clause, since the filtering is done in the database. TheString.StartsWith
method is translated to a SQL LIKE statement.
Remember that you can take a look at the generated SQL by using the DataContext.Log property. This should help you to understand how it works.