SlideShare uma empresa Scribd logo
1 de 18
LINQ & PLINQ (Parallel) Language Integrated Query
Agenda Introduction to LINQ basics Overview of advanced capabilities Demo the Basics PLINQ intro Demo of PLINQ
Introduction LINQ IS... A programming model that Introduces queries as a “first class” concept into .NET More leg room! Is an abstraction level for data Don’t you just love abstraction, it’s great! Is another tool for embedding SQL queries into code “This code was written by a tool” – not that kind of tool! Allows for uniform manipulation of any data type Consistently producing consistent consistency!
LINQ Breakdown
LINQ Breakdown - Compiler
LINQ Implementations LINQ to Objects Code (Reflection), Filesin FileSystem LINQ to ADO.NET LINQ to SQL LINQ to DataSet LINQ to Entities LINQ to XML XDocument, XElement, XAttribute, XNode, etc In System.Xml.Linq.Document
Making Use Of Linq
Exception Handling Calling methods where failure is possible Make use of a ‘let’
Built In Operators Query Where Projection Select SelectMany Ordering OrderBy OrderByDescending ThenBy ThenByDescending Reverse Grouping GroupBy Aggregate Count,  LongCount Sum, Average Aggregate Min, Max Set Distinct Union, Intersect, Except Join Join, GroupJoin Generation Range, Repeat, Empty Quantifiers Any, All, Contains Partitioning Take, TakeWhile Skip, SkipWhile Element Operators First, FirstOrDefault Last, LastOrDefault Single, SingleOrDefault ElemenentAt, ElementAtOrDefatult DefaultIfEmpty Other Concat SequenceEqual
Extension Methods Custom Operators New Name Or Override Existing Operators (potentially bad practice) Specialise Existing – For a given type
LINQ DEMO Basics in VS2010
Advanced LINQ Recursive Lambda Expressions Through the use of Fix fixed-point generator Expression Trees MSDN Blogs: Mads Torgersen - Recursive Lambda Expressions Visitor Pattern using LINQ MSDN Blogs: Jomo Fisher – Dealing with LINQs immutable expression trees
PLINQ Background Part of managed concurrency library in the .NET Framework Simplify concurrent processing Makes use of the Task Parallel Library (TPL) TPL in turn uses Parallel.For Parallel.ForEach Parallel.Invoke
Operating In Parallel Partitioning  Based on computation and data type Range (Arrays, Lists) – Index into structure, equal split Not the most ideal for load balancing Striped Chunks of input Chunk level load balancing Hash Execution On available cores Merge Results Initial thread picks up results (consumer thread) ForAll, Async (pipelining), Sync (stop-and-go) PLINQ takes care of threading events, signalling, concurrency, locking, etc.
PLINQ DEMO Speed up of processing using multiple cores
Demo Projections Extension Methods Parallel Performance LINQ to XML LINQ to SQL Entities
PLINQ Ideal Speedup
Thank You Questions? More info on my blog; links, “refined wording”: http://NickJosevski.com

Mais conteúdo relacionado

Mais procurados

C# Parallel programming
C# Parallel programmingC# Parallel programming
C# Parallel programmingUmeshwaran V
 
The Rise of Functional Programming
The Rise of Functional ProgrammingThe Rise of Functional Programming
The Rise of Functional ProgrammingTjerk Wolterink
 
Module 3: Introduction to LINQ (PowerPoint Slides)
Module 3: Introduction to LINQ (PowerPoint Slides)Module 3: Introduction to LINQ (PowerPoint Slides)
Module 3: Introduction to LINQ (PowerPoint Slides)Mohamed Saleh
 
Whats new in .NET for 2019
Whats new in .NET for 2019Whats new in .NET for 2019
Whats new in .NET for 2019Rory Preddy
 
At Last an OCL Debugger
At Last an OCL DebuggerAt Last an OCL Debugger
At Last an OCL DebuggerEdward Willink
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldZvi Avraham
 
Scala for n00bs by a n00b.
Scala for n00bs by a n00b.Scala for n00bs by a n00b.
Scala for n00bs by a n00b.brandongulla
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaSynesso
 
Re-implementing Thrift using MDE
Re-implementing Thrift using MDERe-implementing Thrift using MDE
Re-implementing Thrift using MDESina Madani
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to ErlangKen Pratt
 
Parallel Execution of Model Management Programs (STAF 2017)
Parallel Execution of Model Management Programs (STAF 2017)Parallel Execution of Model Management Programs (STAF 2017)
Parallel Execution of Model Management Programs (STAF 2017)Sina Madani
 
Natural Language to Visualization by Neural Machine Translation
Natural Language to Visualization by Neural Machine TranslationNatural Language to Visualization by Neural Machine Translation
Natural Language to Visualization by Neural Machine Translationivaderivader
 
Language Integrated Query - LINQ
Language Integrated Query - LINQLanguage Integrated Query - LINQ
Language Integrated Query - LINQDoncho Minkov
 
OCL Integration and Code Generation
OCL Integration and Code GenerationOCL Integration and Code Generation
OCL Integration and Code GenerationEdward Willink
 

Mais procurados (20)

C# Parallel programming
C# Parallel programmingC# Parallel programming
C# Parallel programming
 
The Rise of Functional Programming
The Rise of Functional ProgrammingThe Rise of Functional Programming
The Rise of Functional Programming
 
The OCLforUML Profile
The OCLforUML ProfileThe OCLforUML Profile
The OCLforUML Profile
 
Module 3: Introduction to LINQ (PowerPoint Slides)
Module 3: Introduction to LINQ (PowerPoint Slides)Module 3: Introduction to LINQ (PowerPoint Slides)
Module 3: Introduction to LINQ (PowerPoint Slides)
 
Whats new in .NET for 2019
Whats new in .NET for 2019Whats new in .NET for 2019
Whats new in .NET for 2019
 
Linq
LinqLinq
Linq
 
Link quries
Link quriesLink quries
Link quries
 
At Last an OCL Debugger
At Last an OCL DebuggerAt Last an OCL Debugger
At Last an OCL Debugger
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent World
 
Scala for n00bs by a n00b.
Scala for n00bs by a n00b.Scala for n00bs by a n00b.
Scala for n00bs by a n00b.
 
LINQ
LINQLINQ
LINQ
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Re-implementing Thrift using MDE
Re-implementing Thrift using MDERe-implementing Thrift using MDE
Re-implementing Thrift using MDE
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to Erlang
 
Dynamic in C# 4.0
Dynamic in C# 4.0Dynamic in C# 4.0
Dynamic in C# 4.0
 
Introducing LINQ
Introducing LINQIntroducing LINQ
Introducing LINQ
 
Parallel Execution of Model Management Programs (STAF 2017)
Parallel Execution of Model Management Programs (STAF 2017)Parallel Execution of Model Management Programs (STAF 2017)
Parallel Execution of Model Management Programs (STAF 2017)
 
Natural Language to Visualization by Neural Machine Translation
Natural Language to Visualization by Neural Machine TranslationNatural Language to Visualization by Neural Machine Translation
Natural Language to Visualization by Neural Machine Translation
 
Language Integrated Query - LINQ
Language Integrated Query - LINQLanguage Integrated Query - LINQ
Language Integrated Query - LINQ
 
OCL Integration and Code Generation
OCL Integration and Code GenerationOCL Integration and Code Generation
OCL Integration and Code Generation
 

Destaque

Picnic Software - Developing a flexible and scalable application
Picnic Software - Developing a flexible and scalable applicationPicnic Software - Developing a flexible and scalable application
Picnic Software - Developing a flexible and scalable applicationNick Josevski
 
Thinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick JosevskiThinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick JosevskiNick Josevski
 
HTML5 Fantastic Forms for Mobile Web
HTML5 Fantastic Forms for Mobile Web HTML5 Fantastic Forms for Mobile Web
HTML5 Fantastic Forms for Mobile Web Tammy Butow
 
Linq Sanjay Vyas
Linq   Sanjay VyasLinq   Sanjay Vyas
Linq Sanjay Vyasrsnarayanan
 
LINQ to XML
LINQ to XMLLINQ to XML
LINQ to XMLukdpe
 
Giving Clarity to LINQ Queries by Extending Expressions
Giving Clarity to LINQ Queries by Extending ExpressionsGiving Clarity to LINQ Queries by Extending Expressions
Giving Clarity to LINQ Queries by Extending ExpressionsEd Charbeneau
 
C# 3.0 and LINQ Tech Talk
C# 3.0 and LINQ Tech TalkC# 3.0 and LINQ Tech Talk
C# 3.0 and LINQ Tech TalkMichael Heydt
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Insidejeffz
 
CQRS and what it means for your architecture
CQRS and what it means for your architectureCQRS and what it means for your architecture
CQRS and what it means for your architectureRichard Banks
 

Destaque (20)

Picnic Software - Developing a flexible and scalable application
Picnic Software - Developing a flexible and scalable applicationPicnic Software - Developing a flexible and scalable application
Picnic Software - Developing a flexible and scalable application
 
Thinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick JosevskiThinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world with RavenDB by Nick Josevski
 
HTML5 Fantastic Forms for Mobile Web
HTML5 Fantastic Forms for Mobile Web HTML5 Fantastic Forms for Mobile Web
HTML5 Fantastic Forms for Mobile Web
 
Linq Sanjay Vyas
Linq   Sanjay VyasLinq   Sanjay Vyas
Linq Sanjay Vyas
 
Thinking in linq
Thinking in linqThinking in linq
Thinking in linq
 
LINQ to XML
LINQ to XMLLINQ to XML
LINQ to XML
 
Giving Clarity to LINQ Queries by Extending Expressions
Giving Clarity to LINQ Queries by Extending ExpressionsGiving Clarity to LINQ Queries by Extending Expressions
Giving Clarity to LINQ Queries by Extending Expressions
 
Intake 37 linq3
Intake 37 linq3Intake 37 linq3
Intake 37 linq3
 
Linq to sql
Linq to sqlLinq to sql
Linq to sql
 
C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
C# 3.0 and LINQ Tech Talk
C# 3.0 and LINQ Tech TalkC# 3.0 and LINQ Tech Talk
C# 3.0 and LINQ Tech Talk
 
Understanding linq
Understanding linqUnderstanding linq
Understanding linq
 
LINQ and LINQPad
LINQ and LINQPadLINQ and LINQPad
LINQ and LINQPad
 
Think in linq
Think in linqThink in linq
Think in linq
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
 
LINQ in C#
LINQ in C#LINQ in C#
LINQ in C#
 
Linq
LinqLinq
Linq
 
Of Lambdas and LINQ
Of Lambdas and LINQOf Lambdas and LINQ
Of Lambdas and LINQ
 
CQRS and what it means for your architecture
CQRS and what it means for your architectureCQRS and what it means for your architecture
CQRS and what it means for your architecture
 
LINQ in Unity
LINQ in UnityLINQ in Unity
LINQ in Unity
 

Semelhante a LINQ/PLINQ

Overview Of .Net 4.0 Sanjay Vyas
Overview Of .Net 4.0   Sanjay VyasOverview Of .Net 4.0   Sanjay Vyas
Overview Of .Net 4.0 Sanjay Vyasrsnarayanan
 
Hidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsHidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsAbhishek Sur
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep JoshiSpiffy
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNico Ludwig
 
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
 
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
 
Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0Bruce Johnson
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowKaxil Naik
 
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
 
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource GroupLINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource GroupShahzad
 
Introduction to .NET with C# @ university of wayamba
Introduction to .NET with C# @ university of wayambaIntroduction to .NET with C# @ university of wayamba
Introduction to .NET with C# @ university of wayambaPrageeth Sandakalum
 
How to double .net code value
How to double .net code valueHow to double .net code value
How to double .net code valuejavOnet
 
Parallel Extentions to the .NET Framework
Parallel Extentions to the .NET FrameworkParallel Extentions to the .NET Framework
Parallel Extentions to the .NET Frameworkukdpe
 
The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentThe Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentPython Ireland
 
Parallel Programming in .NET
Parallel Programming in .NETParallel Programming in .NET
Parallel Programming in .NETSANKARSAN BOSE
 
MTaulty_DevWeek_Parallel
MTaulty_DevWeek_ParallelMTaulty_DevWeek_Parallel
MTaulty_DevWeek_Parallelukdpe
 

Semelhante a LINQ/PLINQ (20)

Overview Of .Net 4.0 Sanjay Vyas
Overview Of .Net 4.0   Sanjay VyasOverview Of .Net 4.0   Sanjay Vyas
Overview Of .Net 4.0 Sanjay Vyas
 
Hidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsHidden Facts of .NET Language Gems
Hidden Facts of .NET Language Gems
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
 
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...
 
Linq in C#
Linq in C#Linq in C#
Linq in C#
 
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...
 
Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
Linq
LinqLinq
Linq
 
Why do I Love C#?
Why do I Love C#?Why do I Love C#?
Why do I Love C#?
 
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...
 
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource GroupLINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
 
Introduction to .NET with C# @ university of wayamba
Introduction to .NET with C# @ university of wayambaIntroduction to .NET with C# @ university of wayamba
Introduction to .NET with C# @ university of wayamba
 
How to double .net code value
How to double .net code valueHow to double .net code value
How to double .net code value
 
Parallel Extentions to the .NET Framework
Parallel Extentions to the .NET FrameworkParallel Extentions to the .NET Framework
Parallel Extentions to the .NET Framework
 
EnScript Workshop
EnScript WorkshopEnScript Workshop
EnScript Workshop
 
The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentThe Larch - a visual interactive programming environment
The Larch - a visual interactive programming environment
 
Parallel Programming in .NET
Parallel Programming in .NETParallel Programming in .NET
Parallel Programming in .NET
 
MTaulty_DevWeek_Parallel
MTaulty_DevWeek_ParallelMTaulty_DevWeek_Parallel
MTaulty_DevWeek_Parallel
 

Mais de melbournepatterns (20)

An Introduction to
An Introduction to An Introduction to
An Introduction to
 
State Pattern from GoF
State Pattern from GoFState Pattern from GoF
State Pattern from GoF
 
Iterator Pattern
Iterator PatternIterator Pattern
Iterator Pattern
 
Iterator
IteratorIterator
Iterator
 
Concurrency Patterns
Concurrency PatternsConcurrency Patterns
Concurrency Patterns
 
Continuous Integration, Fast Builds and Flot
Continuous Integration, Fast Builds and FlotContinuous Integration, Fast Builds and Flot
Continuous Integration, Fast Builds and Flot
 
Command Pattern
Command PatternCommand Pattern
Command Pattern
 
Code Contracts API In .Net
Code Contracts API In .NetCode Contracts API In .Net
Code Contracts API In .Net
 
Gpu Cuda
Gpu CudaGpu Cuda
Gpu Cuda
 
Facade Pattern
Facade PatternFacade Pattern
Facade Pattern
 
Phani Kumar - Decorator Pattern
Phani Kumar - Decorator PatternPhani Kumar - Decorator Pattern
Phani Kumar - Decorator Pattern
 
Composite Pattern
Composite PatternComposite Pattern
Composite Pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Prototype Design Pattern
Prototype Design PatternPrototype Design Pattern
Prototype Design Pattern
 
Factory Method Design Pattern
Factory Method Design PatternFactory Method Design Pattern
Factory Method Design Pattern
 
Abstract Factory Design Pattern
Abstract Factory Design PatternAbstract Factory Design Pattern
Abstract Factory Design Pattern
 
A Little Lisp
A Little LispA Little Lisp
A Little Lisp
 
State Pattern in Flex
State Pattern in FlexState Pattern in Flex
State Pattern in Flex
 
Active Object
Active ObjectActive Object
Active Object
 
Extract Composite Talk Andy
Extract Composite Talk AndyExtract Composite Talk Andy
Extract Composite Talk Andy
 

LINQ/PLINQ

  • 1. LINQ & PLINQ (Parallel) Language Integrated Query
  • 2. Agenda Introduction to LINQ basics Overview of advanced capabilities Demo the Basics PLINQ intro Demo of PLINQ
  • 3. Introduction LINQ IS... A programming model that Introduces queries as a “first class” concept into .NET More leg room! Is an abstraction level for data Don’t you just love abstraction, it’s great! Is another tool for embedding SQL queries into code “This code was written by a tool” – not that kind of tool! Allows for uniform manipulation of any data type Consistently producing consistent consistency!
  • 5. LINQ Breakdown - Compiler
  • 6. LINQ Implementations LINQ to Objects Code (Reflection), Filesin FileSystem LINQ to ADO.NET LINQ to SQL LINQ to DataSet LINQ to Entities LINQ to XML XDocument, XElement, XAttribute, XNode, etc In System.Xml.Linq.Document
  • 8. Exception Handling Calling methods where failure is possible Make use of a ‘let’
  • 9. Built In Operators Query Where Projection Select SelectMany Ordering OrderBy OrderByDescending ThenBy ThenByDescending Reverse Grouping GroupBy Aggregate Count, LongCount Sum, Average Aggregate Min, Max Set Distinct Union, Intersect, Except Join Join, GroupJoin Generation Range, Repeat, Empty Quantifiers Any, All, Contains Partitioning Take, TakeWhile Skip, SkipWhile Element Operators First, FirstOrDefault Last, LastOrDefault Single, SingleOrDefault ElemenentAt, ElementAtOrDefatult DefaultIfEmpty Other Concat SequenceEqual
  • 10. Extension Methods Custom Operators New Name Or Override Existing Operators (potentially bad practice) Specialise Existing – For a given type
  • 11. LINQ DEMO Basics in VS2010
  • 12. Advanced LINQ Recursive Lambda Expressions Through the use of Fix fixed-point generator Expression Trees MSDN Blogs: Mads Torgersen - Recursive Lambda Expressions Visitor Pattern using LINQ MSDN Blogs: Jomo Fisher – Dealing with LINQs immutable expression trees
  • 13. PLINQ Background Part of managed concurrency library in the .NET Framework Simplify concurrent processing Makes use of the Task Parallel Library (TPL) TPL in turn uses Parallel.For Parallel.ForEach Parallel.Invoke
  • 14. Operating In Parallel Partitioning Based on computation and data type Range (Arrays, Lists) – Index into structure, equal split Not the most ideal for load balancing Striped Chunks of input Chunk level load balancing Hash Execution On available cores Merge Results Initial thread picks up results (consumer thread) ForAll, Async (pipelining), Sync (stop-and-go) PLINQ takes care of threading events, signalling, concurrency, locking, etc.
  • 15. PLINQ DEMO Speed up of processing using multiple cores
  • 16. Demo Projections Extension Methods Parallel Performance LINQ to XML LINQ to SQL Entities
  • 18. Thank You Questions? More info on my blog; links, “refined wording”: http://NickJosevski.com