SlideShare una empresa de Scribd logo
1 de 23
Road to Dynamic
LINQ
Vedran Maršić AKA Fosna
Warning: Expression Trees Ahead
About me
 Vedran Maršić AKA Fosna
 dev at http://www.axilis.com/author/vmarsic/
 organizing programming workshops for kids
 Logo, Scratch, HTML, CSS, JavaScript, Python, C++
We’ll cover
 Part 1
 What is expression tree in C#
 How is it different from similar looking lambda delegates
 How to build expression trees
 How to parse expression trees
 Where are you already using them
 Part 2
 Check out few expression tree exploits
 Point to brilliant, not easy to understand, ideas or projects from some cool developer
maniacs 
We won’t cover
 Implementing LINQ providers
 Implementing deep copy
 Implementing faster static dictionary
 Implementing IoC container
Introduction to Expression
Trees
Expression Tree Nodes
Plain old C#
• c = a + b
Lambda expression
• (a, b) => a + b
Gists:
AddStatement.linq
SimpleBinaryExpression.linq
Definition
 represent code in a tree-like data structure
 not in MSIL (Microsoft Intermediate Language)
 each node is an expression
 has compiler smell all over it
 can compile to get functions!
 get some good ol’ MSIL
 MSIL ex:
IL_0007: ldloc.0 // a
IL_0008: ldloc.1 // b
IL_0009: add
IL_000A: stloc.2 // c
History
 Came with .NET 3.5
 Built some muscle in .NET 4.0
 ‘nuff said 
Expression Tree Dissection
x => x < 5
Gist: SimpleLogicalExpression.linq
Why Expression Tree?
analyze expression tree
discover what you want done
decide how to do it
Expression Trees Vs Lambda Delegates
One lambda expression
(a, b) => a + b
Expression Trees Vs Lambda Delegates
One lambda expression
(a, b) => a + b
Two type signatures
Expression Trees Vs Lambda Delegates
...
Gist: TreeVsDelegate.linq
Applied Expression Trees Vs Lambda Delegates
 Which technology exploits expression trees and which one doesn’t?
 LINQ to Objects
 LINQ to Entities (EF)
 LINQ to XML
 Parallel LINQ
How to Create an Expression Tree?
 From lambda expression at compile time
 Method invocation flavor
 Query syntax
 Using Expression API at run time
 Why would anyone do that?
Gist: BuildExp.linq
Famous Extension Methods
...attached to Clever Interfaces
Lazy: AsEnumerable()
 If code can be executed in process then the job can be done with the
simple type called IEnumerable<T>
 remember yield return
Lazy: AsQueryable()
 If you need to translate a query expression into a string that will be passed
to another process, then use IQueryable<T> and expression trees.
Eager Extension Methods
• ToList()
• ToArray()
• ToDictionary()
• ToLookup()
• First()
• FirstOrDefault()
• Single()
• SingleOrDefault()
Applied Expression Trees
Next time...
Thanks. Bye!
No questions, right?
Resources
 Start with
 http://stackoverflow.com/a/403233/953338
 Expression Tree Basics, Charlie Calvert 31 Jan 2008 3:49 AM
 http://blogs.msdn.com/b/charlie/archive/2008/01/31/expression-tree-basics.aspx
 Published by Olexander Ivanitskyi on Tuesday, June 11, 2013
 LINQ: Func<T> vs. Expression<Func<T>>
 http://ivanitskyi.blogspot.hr/2013/06/linq-func-vs-expression.html
 asked Apr 27 '09 at 13:50, Richard Nagle
 Why would you use Expression<Func<T>> rather than Func<T>?
 http://stackoverflow.com/questions/793571/why-would-you-use-expressionfunct-
rather-than-funct
Resources
 C# 6.0 Features
 https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6
 Canonical Functions
 https://msdn.microsoft.com/en-us/library/vstudio/bb738626(v=vs.100).aspx
 The .NET Programmer’s Playground - LinqPad
 http://www.linqpad.net/

Más contenido relacionado

La actualidad más candente

To Lombok or not to Lombok | J-Fall 2019
To Lombok or not to Lombok | J-Fall 2019To Lombok or not to Lombok | J-Fall 2019
To Lombok or not to Lombok | J-Fall 2019Kaya Weers
 
Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Alexey Diyan
 
Xtext beyond the defaults - how to tackle performance problems
Xtext beyond the defaults -  how to tackle performance problemsXtext beyond the defaults -  how to tackle performance problems
Xtext beyond the defaults - how to tackle performance problemsHolger Schill
 
Intro to Java for C++ Developers
Intro to Java for C++ DevelopersIntro to Java for C++ Developers
Intro to Java for C++ DevelopersZachary Blair
 
An Introduction to ANTLR
An Introduction to ANTLRAn Introduction to ANTLR
An Introduction to ANTLRMorteza Zakeri
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testingKnoldus Inc.
 
Using PowerShell as DSL in .Net applications
Using PowerShell as DSL in .Net applicationsUsing PowerShell as DSL in .Net applications
Using PowerShell as DSL in .Net applicationsJoy George
 
Nakov dot net-framework-overview-english
Nakov dot net-framework-overview-englishNakov dot net-framework-overview-english
Nakov dot net-framework-overview-englishsrivathsan.10
 
C# and the Evolution of a Programming Language
C# and the Evolution of a Programming LanguageC# and the Evolution of a Programming Language
C# and the Evolution of a Programming LanguageJacinto Limjap
 
C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?Christian Nagel
 
Object Oriented Programming Languages
Object Oriented Programming LanguagesObject Oriented Programming Languages
Object Oriented Programming LanguagesMannu Khani
 
CLTL: Description of web services and sofware. Nijmegen 2013
CLTL: Description of web services and sofware. Nijmegen 2013CLTL: Description of web services and sofware. Nijmegen 2013
CLTL: Description of web services and sofware. Nijmegen 2013Rubén Izquierdo Beviá
 
Internal domain-specific languages
Internal domain-specific languagesInternal domain-specific languages
Internal domain-specific languagesMikhail Barash
 

La actualidad más candente (20)

To Lombok or not to Lombok | J-Fall 2019
To Lombok or not to Lombok | J-Fall 2019To Lombok or not to Lombok | J-Fall 2019
To Lombok or not to Lombok | J-Fall 2019
 
Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...
 
05 functional programming
05 functional programming05 functional programming
05 functional programming
 
Xtext beyond the defaults - how to tackle performance problems
Xtext beyond the defaults -  how to tackle performance problemsXtext beyond the defaults -  how to tackle performance problems
Xtext beyond the defaults - how to tackle performance problems
 
Intro to Java for C++ Developers
Intro to Java for C++ DevelopersIntro to Java for C++ Developers
Intro to Java for C++ Developers
 
An Introduction to ANTLR
An Introduction to ANTLRAn Introduction to ANTLR
An Introduction to ANTLR
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testing
 
Using PowerShell as DSL in .Net applications
Using PowerShell as DSL in .Net applicationsUsing PowerShell as DSL in .Net applications
Using PowerShell as DSL in .Net applications
 
Nakov dot net-framework-overview-english
Nakov dot net-framework-overview-englishNakov dot net-framework-overview-english
Nakov dot net-framework-overview-english
 
DSL explained _
DSL explained _DSL explained _
DSL explained _
 
C# and the Evolution of a Programming Language
C# and the Evolution of a Programming LanguageC# and the Evolution of a Programming Language
C# and the Evolution of a Programming Language
 
C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
ANTLR4 in depth
ANTLR4 in depthANTLR4 in depth
ANTLR4 in depth
 
Object Oriented Programming Languages
Object Oriented Programming LanguagesObject Oriented Programming Languages
Object Oriented Programming Languages
 
CLTL: Description of web services and sofware. Nijmegen 2013
CLTL: Description of web services and sofware. Nijmegen 2013CLTL: Description of web services and sofware. Nijmegen 2013
CLTL: Description of web services and sofware. Nijmegen 2013
 
Swift vs. Language X
Swift vs. Language XSwift vs. Language X
Swift vs. Language X
 
Internal domain-specific languages
Internal domain-specific languagesInternal domain-specific languages
Internal domain-specific languages
 
20 intro-to-csharp
20 intro-to-csharp20 intro-to-csharp
20 intro-to-csharp
 

Similar a Road to Dynamic LINQ Part 1

Project_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalProject_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalJerin John
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Insidejeffz
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...Maarten Balliauw
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
Asp.net c# mvc Training-Day-5 of Day-9
Asp.net c# mvc Training-Day-5 of Day-9Asp.net c# mvc Training-Day-5 of Day-9
Asp.net c# mvc Training-Day-5 of Day-9AHM Pervej Kabir
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaDmitry Buzdin
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
Architecting Domain-Specific Languages
Architecting Domain-Specific LanguagesArchitecting Domain-Specific Languages
Architecting Domain-Specific LanguagesMarkus Voelter
 
C# advanced topics and future - C#5
C# advanced topics and future - C#5C# advanced topics and future - C#5
C# advanced topics and future - C#5Peter Gfader
 
Compiler design Introduction
Compiler design IntroductionCompiler design Introduction
Compiler design IntroductionAman Sharma
 
Class 6: Introduction to web technology entrepreneurship
Class 6: Introduction to web technology entrepreneurshipClass 6: Introduction to web technology entrepreneurship
Class 6: Introduction to web technology entrepreneurshipallanchao
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Wei Sun
 
Code Analysis and Refactoring with CDT
Code Analysis and Refactoring with CDTCode Analysis and Refactoring with CDT
Code Analysis and Refactoring with CDTdschaefer
 
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...Codemotion
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
 
C#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New FeaturesC#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New Featurestechfreak
 
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...Prof Chethan Raj C
 
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...Codemotion
 

Similar a Road to Dynamic LINQ Part 1 (20)

Project_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_finalProject_Report (BARC-Jerin)_final
Project_Report (BARC-Jerin)_final
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
Asp.net c# mvc Training-Day-5 of Day-9
Asp.net c# mvc Training-Day-5 of Day-9Asp.net c# mvc Training-Day-5 of Day-9
Asp.net c# mvc Training-Day-5 of Day-9
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Architecting Domain-Specific Languages
Architecting Domain-Specific LanguagesArchitecting Domain-Specific Languages
Architecting Domain-Specific Languages
 
C# advanced topics and future - C#5
C# advanced topics and future - C#5C# advanced topics and future - C#5
C# advanced topics and future - C#5
 
DevNation
DevNation DevNation
DevNation
 
Compiler design Introduction
Compiler design IntroductionCompiler design Introduction
Compiler design Introduction
 
Class 6: Introduction to web technology entrepreneurship
Class 6: Introduction to web technology entrepreneurshipClass 6: Introduction to web technology entrepreneurship
Class 6: Introduction to web technology entrepreneurship
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02
 
Code Analysis and Refactoring with CDT
Code Analysis and Refactoring with CDTCode Analysis and Refactoring with CDT
Code Analysis and Refactoring with CDT
 
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
C#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New FeaturesC#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New Features
 
Intro1
Intro1Intro1
Intro1
 
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
 
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
 

Más de Axilis

Web App Security for Devs
Web App Security for DevsWeb App Security for Devs
Web App Security for DevsAxilis
 
React tips
React tipsReact tips
React tipsAxilis
 
Configuring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversConfiguring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversAxilis
 
Journey to Microservice architecture via Amazon Lambda
Journey to Microservice architecture via Amazon LambdaJourney to Microservice architecture via Amazon Lambda
Journey to Microservice architecture via Amazon LambdaAxilis
 
Should you react?
Should you react?Should you react?
Should you react?Axilis
 
Sweet ES2015 (ES6) Taste
Sweet ES2015 (ES6) TasteSweet ES2015 (ES6) Taste
Sweet ES2015 (ES6) TasteAxilis
 
NuGet Must Haves for LINQ
NuGet Must Haves for LINQNuGet Must Haves for LINQ
NuGet Must Haves for LINQAxilis
 
Quick introduction to zeplin
Quick introduction to zeplinQuick introduction to zeplin
Quick introduction to zeplinAxilis
 
Diving into Node with Express and Mongo
Diving into Node with Express and MongoDiving into Node with Express and Mongo
Diving into Node with Express and MongoAxilis
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The BeginningAxilis
 
.NET Core - Sve što trebate znati
.NET Core - Sve što trebate znati.NET Core - Sve što trebate znati
.NET Core - Sve što trebate znatiAxilis
 
Angular Translate
Angular TranslateAngular Translate
Angular TranslateAxilis
 
NPM, Bower and Gulp Kickstart in Visual Studio
 NPM, Bower and Gulp Kickstart in Visual Studio NPM, Bower and Gulp Kickstart in Visual Studio
NPM, Bower and Gulp Kickstart in Visual StudioAxilis
 
Dive Into Swift
Dive Into SwiftDive Into Swift
Dive Into SwiftAxilis
 
Python Tools for Visual Studio
Python Tools for Visual StudioPython Tools for Visual Studio
Python Tools for Visual StudioAxilis
 
Python Tools for Visual Studio
Python Tools for Visual StudioPython Tools for Visual Studio
Python Tools for Visual StudioAxilis
 
Wireframing
WireframingWireframing
WireframingAxilis
 
Angular 2.0: Getting ready
Angular 2.0: Getting readyAngular 2.0: Getting ready
Angular 2.0: Getting readyAxilis
 
Angular JS deep dive
Angular JS deep diveAngular JS deep dive
Angular JS deep diveAxilis
 
Micro ORM vs Entity Framework
Micro ORM vs Entity FrameworkMicro ORM vs Entity Framework
Micro ORM vs Entity FrameworkAxilis
 

Más de Axilis (20)

Web App Security for Devs
Web App Security for DevsWeb App Security for Devs
Web App Security for Devs
 
React tips
React tipsReact tips
React tips
 
Configuring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversConfiguring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky servers
 
Journey to Microservice architecture via Amazon Lambda
Journey to Microservice architecture via Amazon LambdaJourney to Microservice architecture via Amazon Lambda
Journey to Microservice architecture via Amazon Lambda
 
Should you react?
Should you react?Should you react?
Should you react?
 
Sweet ES2015 (ES6) Taste
Sweet ES2015 (ES6) TasteSweet ES2015 (ES6) Taste
Sweet ES2015 (ES6) Taste
 
NuGet Must Haves for LINQ
NuGet Must Haves for LINQNuGet Must Haves for LINQ
NuGet Must Haves for LINQ
 
Quick introduction to zeplin
Quick introduction to zeplinQuick introduction to zeplin
Quick introduction to zeplin
 
Diving into Node with Express and Mongo
Diving into Node with Express and MongoDiving into Node with Express and Mongo
Diving into Node with Express and Mongo
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The Beginning
 
.NET Core - Sve što trebate znati
.NET Core - Sve što trebate znati.NET Core - Sve što trebate znati
.NET Core - Sve što trebate znati
 
Angular Translate
Angular TranslateAngular Translate
Angular Translate
 
NPM, Bower and Gulp Kickstart in Visual Studio
 NPM, Bower and Gulp Kickstart in Visual Studio NPM, Bower and Gulp Kickstart in Visual Studio
NPM, Bower and Gulp Kickstart in Visual Studio
 
Dive Into Swift
Dive Into SwiftDive Into Swift
Dive Into Swift
 
Python Tools for Visual Studio
Python Tools for Visual StudioPython Tools for Visual Studio
Python Tools for Visual Studio
 
Python Tools for Visual Studio
Python Tools for Visual StudioPython Tools for Visual Studio
Python Tools for Visual Studio
 
Wireframing
WireframingWireframing
Wireframing
 
Angular 2.0: Getting ready
Angular 2.0: Getting readyAngular 2.0: Getting ready
Angular 2.0: Getting ready
 
Angular JS deep dive
Angular JS deep diveAngular JS deep dive
Angular JS deep dive
 
Micro ORM vs Entity Framework
Micro ORM vs Entity FrameworkMicro ORM vs Entity Framework
Micro ORM vs Entity Framework
 

Último

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

Road to Dynamic LINQ Part 1

  • 1. Road to Dynamic LINQ Vedran Maršić AKA Fosna Warning: Expression Trees Ahead
  • 2. About me  Vedran Maršić AKA Fosna  dev at http://www.axilis.com/author/vmarsic/  organizing programming workshops for kids  Logo, Scratch, HTML, CSS, JavaScript, Python, C++
  • 3. We’ll cover  Part 1  What is expression tree in C#  How is it different from similar looking lambda delegates  How to build expression trees  How to parse expression trees  Where are you already using them  Part 2  Check out few expression tree exploits  Point to brilliant, not easy to understand, ideas or projects from some cool developer maniacs 
  • 4. We won’t cover  Implementing LINQ providers  Implementing deep copy  Implementing faster static dictionary  Implementing IoC container
  • 6. Expression Tree Nodes Plain old C# • c = a + b Lambda expression • (a, b) => a + b Gists: AddStatement.linq SimpleBinaryExpression.linq
  • 7. Definition  represent code in a tree-like data structure  not in MSIL (Microsoft Intermediate Language)  each node is an expression  has compiler smell all over it  can compile to get functions!  get some good ol’ MSIL  MSIL ex: IL_0007: ldloc.0 // a IL_0008: ldloc.1 // b IL_0009: add IL_000A: stloc.2 // c
  • 8. History  Came with .NET 3.5  Built some muscle in .NET 4.0  ‘nuff said 
  • 9. Expression Tree Dissection x => x < 5 Gist: SimpleLogicalExpression.linq
  • 10. Why Expression Tree? analyze expression tree discover what you want done decide how to do it
  • 11. Expression Trees Vs Lambda Delegates One lambda expression (a, b) => a + b
  • 12. Expression Trees Vs Lambda Delegates One lambda expression (a, b) => a + b Two type signatures
  • 13. Expression Trees Vs Lambda Delegates ... Gist: TreeVsDelegate.linq
  • 14. Applied Expression Trees Vs Lambda Delegates  Which technology exploits expression trees and which one doesn’t?  LINQ to Objects  LINQ to Entities (EF)  LINQ to XML  Parallel LINQ
  • 15. How to Create an Expression Tree?  From lambda expression at compile time  Method invocation flavor  Query syntax  Using Expression API at run time  Why would anyone do that? Gist: BuildExp.linq
  • 16. Famous Extension Methods ...attached to Clever Interfaces
  • 17. Lazy: AsEnumerable()  If code can be executed in process then the job can be done with the simple type called IEnumerable<T>  remember yield return
  • 18. Lazy: AsQueryable()  If you need to translate a query expression into a string that will be passed to another process, then use IQueryable<T> and expression trees.
  • 19. Eager Extension Methods • ToList() • ToArray() • ToDictionary() • ToLookup() • First() • FirstOrDefault() • Single() • SingleOrDefault()
  • 22. Resources  Start with  http://stackoverflow.com/a/403233/953338  Expression Tree Basics, Charlie Calvert 31 Jan 2008 3:49 AM  http://blogs.msdn.com/b/charlie/archive/2008/01/31/expression-tree-basics.aspx  Published by Olexander Ivanitskyi on Tuesday, June 11, 2013  LINQ: Func<T> vs. Expression<Func<T>>  http://ivanitskyi.blogspot.hr/2013/06/linq-func-vs-expression.html  asked Apr 27 '09 at 13:50, Richard Nagle  Why would you use Expression<Func<T>> rather than Func<T>?  http://stackoverflow.com/questions/793571/why-would-you-use-expressionfunct- rather-than-funct
  • 23. Resources  C# 6.0 Features  https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6  Canonical Functions  https://msdn.microsoft.com/en-us/library/vstudio/bb738626(v=vs.100).aspx  The .NET Programmer’s Playground - LinqPad  http://www.linqpad.net/