Expression Trees<br />How to…<br />YuriySeniuk<br />http://yuriyseniuk.blogspot.com/<br />
What is Expression Trees<br />Is a Tree<br />Has 56 Expressions<br />Add, Bind, Block, Break, Call, Catch, Coalesce, Conti...
How to Build?<br />Func<int, int> myDelegate = (a, b) => a + b; <br />Expression<Func<int, int>> myExpression = (a, b) => ...
How to Use?<br />BinaryExpressionmyExpression = Expression.Add( Expression.Constant( 2 ), Expression.Constant( 5 ) );<br /...
Where can be useful?<br />Dynamic code;<br />Object cloning;<br />Alternative for reflection;<br />Transform a domain lang...
Any questions?<br />?<br />
Links<br />http://habrahabr.ru/blogs/net/83169/<br />http://www.i-programmer.info/programming/c/869-lambda-expressions-exp...
Upcoming SlideShare
Loading in …5
×

Expression trees

1,195 views

Published on

Express presentation about expression trees

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,195
On SlideShare
0
From Embeds
0
Number of Embeds
65
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Expression trees

  1. 1. Expression Trees<br />How to…<br />YuriySeniuk<br />http://yuriyseniuk.blogspot.com/<br />
  2. 2. What is Expression Trees<br />Is a Tree<br />Has 56 Expressions<br />Add, Bind, Block, Break, Call, Catch, Coalesce, Continue, Equal, GreaterThan, Lambda, Loop, New, Or , PowerAssign ……………<br />Expression: 5 + 4 * 3<br />+<br />5<br />*<br />4<br />3<br />
  3. 3. How to Build?<br />Func<int, int> myDelegate = (a, b) => a + b; <br />Expression<Func<int, int>> myExpression = (a, b) => a + b;<br />BinaryExpressionmyExpression = <br />Expression.Add( Expression.Constant( 2 ), Expression.Constant( 5 ) );<br />
  4. 4. How to Use?<br />BinaryExpressionmyExpression = Expression.Add( Expression.Constant( 2 ), Expression.Constant( 5 ) );<br />var compiled = Expression.Lambda<Func<int>>( myExpression ).Compile();<br />compiled();<br />Expression<Func<int, bool>> expr = num => num < 5; <br />Func<int, bool> compiled = expr.Compile();<br />compiled (4);<br />
  5. 5. Where can be useful?<br />Dynamic code;<br />Object cloning;<br />Alternative for reflection;<br />Transform a domain language into executable code;<br />Patterns code improvement.<br />
  6. 6. Any questions?<br />?<br />
  7. 7. Links<br />http://habrahabr.ru/blogs/net/83169/<br />http://www.i-programmer.info/programming/c/869-lambda-expressions-expressiontrees.html?start=1<br />http://www.abhisheksur.com/2010/09/use-of-expression-trees-in-lamda-c.html<br />http://geekswithblogs.net/Martinez/articles/understanding-expression-trees.aspx<br />http://msdn.microsoft.com/en-us/library/system.linq.expressions.expression.aspx<br />

×