Linq plinq
Download
1 / 18

LINQ PLINQ - PowerPoint PPT Presentation


  • 147 Views
  • Uploaded on

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!

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'LINQ PLINQ' - murray


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Linq plinq l.jpg

LINQ & PLINQ

(Parallel) Language Integrated Query


Agenda l.jpg
Agenda

  • Introduction to LINQ basics

  • Overview of advanced capabilities

  • Demo the Basics

  • PLINQ intro

  • Demo of PLINQ


Introduction l.jpg
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 implementations l.jpg
    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



    Exception handling l.jpg
    Exception Handling

    • Calling methods where failure is possible

    • Make use of a ‘let’


    Built in operators l.jpg
    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 l.jpg
    Extension Methods

    • Custom Operators

      • New Name

      • Or Override Existing Operators (potentially bad practice)

        • Specialise Existing – For a given type


    Linq demo l.jpg
    LINQ DEMO

    Basics in VS2010


    Advanced linq l.jpg
    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 l.jpg
    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 l.jpg
    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 l.jpg
    PLINQ DEMO

    Speed up of processing using multiple cores


    Slide16 l.jpg
    Demo

    • Projections

    • Extension Methods

    • Parallel Performance

    • LINQ to XML

    • LINQ to SQL Entities



    Thank you l.jpg
    Thank You

    Questions?

    More info on my blog; links, “refined wording”: http://NickJosevski.com


    ad