The LINQ to SQL return object were implementing IQueryable
interface. So for Select
method predicate parameter you should only supply single lambda expression without body.
This is because LINQ for SQL code is not execute inside program rather than on remote side like SQL server or others. This lazy loading execution type were achieve by implementing IQueryable where its expect delegate is being wrapped in Expression type class like below.
Expression<Func<TParam,TResult>>
Expression tree do not support lambda expression with body and its only support single line lambda expression like var id = cols.Select( col => col.id );
So if you try the following code won't works.
Expression<Func<int,int>> function = x => {
return x * 2;
}
The following will works as per expected.
Expression<Func<int,int>> function = x => x * 2;