SlideShare a Scribd company logo
1 of 11
Expression Tree
Jason
Expression tree
Expression trees represent code in a tree-like data structure, where each node is
an expression.
This enables dynamic modification of executable code, the execution of LINQ
queries in various databases, and the creation of dynamic queries.
Lambda
Statement lambda
(x, y) => { return x + y; }
Expression lambda
(x, y) => x + y
Lambda Expression
Using the System.Linq.Expressions namespace
Expression<Func<int, bool>> expr = n => n > 5;
Expression<TDelegate>.Compile
Compile the expression tree into executable code.
Expression<Func<int, bool>> expr = n => n > 5;
Func<int, bool> deleg = expr.Compile();
deleg(3);
Expression<Func<int, bool>>
n => n > 5
Body : BinaryExpression
n > 5
Left : Expression
n
Right : Expression
5
NodeType : ExpressionType
GreaterThan
NodeType : ExpressionType
Lambda
ReturnType : Type
Boolean
ParameterExpression
ParameterExpression iParam =
Expression.Parameter(typeof(int), "n");
>
n 5
λ
BinaryExpression
BinaryExpression binaryExpr =
Expression.GreaterThan(iParam, constantExpr);
>
n 5
λ
ConstantExpression
ConstantExpression constantExpr =
Expression.Constant(5, typeof(int));
>
n 5
λ
LambdaExpression
Expression<Func<int, bool>> expr =
Expression.Lambda<Func<int, bool>>(binaryExpr, iParam);
>
n 5
λ
Reference
Expression Tree - MSDN
https://msdn.microsoft.com/en-us/library/bb397951.aspx

More Related Content

What's hot

Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
Niraj Agarwal
 

What's hot (19)

Syntax-Directed Translation into Three Address Code
Syntax-Directed Translation into Three Address CodeSyntax-Directed Translation into Three Address Code
Syntax-Directed Translation into Three Address Code
 
Programming in Scala - Lecture Four
Programming in Scala - Lecture FourProgramming in Scala - Lecture Four
Programming in Scala - Lecture Four
 
Unit iii
Unit iiiUnit iii
Unit iii
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
 
Unit v
Unit vUnit v
Unit v
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8
 
Compiler notes--unit-iii
Compiler notes--unit-iiiCompiler notes--unit-iii
Compiler notes--unit-iii
 
C intro
C introC intro
C intro
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
 
Basics of Python Programming
Basics of Python ProgrammingBasics of Python Programming
Basics of Python Programming
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
 
C# String
C# StringC# String
C# String
 
Ch13
Ch13Ch13
Ch13
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
 
pyton Notes6
 pyton Notes6 pyton Notes6
pyton Notes6
 
Python-03| Data types
Python-03| Data typesPython-03| Data types
Python-03| Data types
 
expressions
expressionsexpressions
expressions
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
Module 3-Functions
Module 3-FunctionsModule 3-Functions
Module 3-Functions
 

Viewers also liked (19)

Power shell object
Power shell objectPower shell object
Power shell object
 
Bootstrap–component
Bootstrap–componentBootstrap–component
Bootstrap–component
 
Vic weekly learning_20151120
Vic weekly learning_20151120Vic weekly learning_20151120
Vic weekly learning_20151120
 
React.js 20150828
React.js 20150828React.js 20150828
React.js 20150828
 
20121228 jqueryui - button - By Nat
20121228 jqueryui - button - By Nat20121228 jqueryui - button - By Nat
20121228 jqueryui - button - By Nat
 
20120601_Excel 元件 ep plus joncash
20120601_Excel 元件 ep plus joncash20120601_Excel 元件 ep plus joncash
20120601_Excel 元件 ep plus joncash
 
JSRender
JSRenderJSRender
JSRender
 
Covariance, contravariance 觀念分享
Covariance, contravariance 觀念分享Covariance, contravariance 觀念分享
Covariance, contravariance 觀念分享
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Mvc route
Mvc routeMvc route
Mvc route
 
20121228 jQueryui - datepicker - By Jason
20121228 jQueryui - datepicker - By Jason20121228 jQueryui - datepicker - By Jason
20121228 jQueryui - datepicker - By Jason
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
20120601_jquery tree traversal_drake
20120601_jquery tree traversal_drake20120601_jquery tree traversal_drake
20120601_jquery tree traversal_drake
 
What is new in visual studio 2015
What is new in visual studio 2015What is new in visual studio 2015
What is new in visual studio 2015
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
 
PostCss
PostCssPostCss
PostCss
 
Expression tree
Expression treeExpression tree
Expression tree
 
ReactJs
ReactJsReactJs
ReactJs
 

Similar to Expression tree

Ti1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismTi1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: Polymorphism
Eelco Visser
 

Similar to Expression tree (20)

Ti1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: PolymorphismTi1220 Lecture 7: Polymorphism
Ti1220 Lecture 7: Polymorphism
 
Functions In Scala
Functions In Scala Functions In Scala
Functions In Scala
 
Understanding linq
Understanding linqUnderstanding linq
Understanding linq
 
C# programming
C# programming C# programming
C# programming
 
php&mysql with Ethical Hacking
php&mysql with Ethical Hackingphp&mysql with Ethical Hacking
php&mysql with Ethical Hacking
 
04_python_functions.ppt You can define functions to provide the required func...
04_python_functions.ppt You can define functions to provide the required func...04_python_functions.ppt You can define functions to provide the required func...
04_python_functions.ppt You can define functions to provide the required func...
 
Linq and lambda
Linq and lambdaLinq and lambda
Linq and lambda
 
Functions & Closures in Scala
Functions & Closures in ScalaFunctions & Closures in Scala
Functions & Closures in Scala
 
Functions & Closures in Scala
Functions & Closures in ScalaFunctions & Closures in Scala
Functions & Closures in Scala
 
Functions & closures
Functions & closuresFunctions & closures
Functions & closures
 
Testing for share
Testing for share Testing for share
Testing for share
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 
Functional programming with FSharp
Functional programming with FSharpFunctional programming with FSharp
Functional programming with FSharp
 
Lesson11
Lesson11Lesson11
Lesson11
 
Introduction To Programming with Python-1
Introduction To Programming with Python-1Introduction To Programming with Python-1
Introduction To Programming with Python-1
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Python Programming Basics for begginners
Python Programming Basics for begginnersPython Programming Basics for begginners
Python Programming Basics for begginners
 
CC Week 11.ppt
CC Week 11.pptCC Week 11.ppt
CC Week 11.ppt
 
Fuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional ProgrammingFuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional Programming
 

More from LearningTech (20)

vim
vimvim
vim
 
Docker
DockerDocker
Docker
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
node.js errors
node.js errorsnode.js errors
node.js errors
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection &amp; activator
Reflection &amp; activatorReflection &amp; activator
Reflection &amp; activator
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 
Asp.net MVC DI
Asp.net MVC DIAsp.net MVC DI
Asp.net MVC DI
 
Vic weekly learning_20151127
Vic weekly learning_20151127Vic weekly learning_20151127
Vic weekly learning_20151127
 
Mocha.js
Mocha.jsMocha.js
Mocha.js
 
R language
R languageR language
R language
 
20151120 ian cocos2d js
20151120 ian cocos2d js20151120 ian cocos2d js
20151120 ian cocos2d js
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Recently uploaded (20)

Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 

Expression tree

Editor's Notes

  1. https://msdn.microsoft.com/zh-tw/library/bb361179(v=vs.110).aspx