Behind the scenes, there's some translations going on.
For LINQ to SQL (and LINQ to Entities), the select keyword effectively ends a query. So, the second example has the filter as part of the SQL query, while the first one executes after the query.
There's a third way to do a LINQ query, called fluent syntax:
var movies = db.Movies.Where(s => s.Title.Contains(searchString));
If you look at the signature of Where, you'd find this:
IQueryable<T> Where(IQueryable<T> source, Expression<Func<T,bool>> predicate);
The key thing is the type of predicate
: it's an expression of a (lambda) function, rather than merely a (lambda) function. This lets .Net dynamically convert the Expression
object to SQL. For the query syntax, this parsing ends at select
.