Lambdas can be emitted both as Func and Expression

suggest change

Assuming the following Person class:

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}

The following lambda:

p => p.Age > 18

can be passed as an argument to both methods:

public void AsFunc(Func<Person, bool> func)
public void AsExpression(Expression<Func<Person, bool>> expr)

The compiler can turn an expression-bodied lambda into either a delegate or an expression tree. A statement-bodied lambda can become a delegate, but not an expression tree.

LINQ providers rely on expression trees, mainly through IQueryable<T>, to parse a query and translate it into a store query.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents