Reputation: 89
Can anyone explain what is the use of expressions<func>
?
Upvotes: 1
Views: 231
Reputation: 180
You may want to start here
A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.
Upvotes: 0
Reputation: 5404
I'm going to assume you mean Expression<Func>
where Func
is any variety of the generic Func
delegate.
If this is to be the case, what Expression<Func>
is doing is getting an expression tree of the lambda that you're passing in its place. You'll find this most commonly on the variants of IQueryable<T>
or in many fluent interfaces.
The expression trees are used at run-time to generally translate the lambda expression into some other format. Such as SQL in the case of LINQ to SQL.
You can read up more on Expression
And more about expression trees in .NET
Upvotes: 2
Reputation: 8152
From MSDN:
Represents a strongly typed lambda expression as a data structure in the form of an expression tree
Here's a real world example of it's use that shows why it's useful: http://www.albahari.com/nutshell/predicatebuilder.aspx
Upvotes: 0
Reputation: 16018
Expression trees represent code in a tree-like data structure, where each node is an expression, for example, a method call or a binary operation such as x < y
You can read more in this article.
Upvotes: 0