SlideShare a Scribd company logo
1 of 21
The LINQ Project Standard Query Operators DLinq (ADO.NET) XLinq (System.Xml) .NET Language Integrated Query C# VB Others… Objects <book> <title/> <author/> <year/> <price/> </book> XML SQL WinFS
Language Integrated Query
How does it work? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
C# 3.0 Language Innovations var contacts = from c in customers where c.State == &quot;WA&quot; select new { c.Name, c.Phone }; var contacts = customers .Where(c => c.State == &quot;WA&quot;) .Select(c => new { c.Name, c.Phone }); Extension methods Lambda expressions Query expressions Object initializers Anonymous types Local variable type inference
Lambda Expressions and Extension Methods
Object Initializers public class Rectangle { private Point p1 = new Point(); private Point p2 = new Point(); public Point P1 { get { return p1; } } public Point P2 { get { return p2; } } } Rectangle r = new Rectangle { P1 = { X = 0, Y = 1 }, P2 = { X = 2, Y = 3 } }; Rectangle r = new Rectangle(); r.P1.X = 0; r.P1.Y = 1; r.P2.X = 2; r.P2.Y = 3; Embedded objects No “new Point” Read-only properties
Local Variable Type Inference int i = 5; string s = &quot;Hello&quot;; double d = 1.0; int[] numbers = new int[] {1, 2, 3}; Dictionary<int,Order> orders = new Dictionary<int,Order>(); var i = 5; var s = &quot;Hello&quot;; var d = 1.0; var numbers = new int[] {1, 2, 3}; var orders = new Dictionary<int,Order>(); “ var” means same type as initializer
Anonymous Types public class Customer { public string Name; public Address Address; public string Phone; public List<Order> Orders; … } public class Contact { public string Name; public string Phone; } Customer c = GetCustomer(…); Contact x =  new Contact { Name = c.Name, Phone = c.Phone } ; Customer c = GetCustomer(…); var x =  new { c.Name, c.Phone } ; Customer c = GetCustomer(…); var x =  new { Name = c.Name, Phone = c.Phone } ; class ??? { public string Name; public string Phone; } Projection style initializer
Query Expressions ,[object Object],from   id   in   source {  from   id   in   source  |  where   condition  } [  orderby   ordering ,  ordering , … ] select   expr  |  group   expr   by   key [  into   id   query  ] Starts with  from Zero or more  from  or  where Optional  orderby Ends with  select  or  group   by Optional  into  continuation
Query Expressions ,[object Object],[object Object],from c in customers where c.State == &quot;WA&quot; select new { c.Name, c.Phone }; customers .Where(c => c.State == &quot;WA&quot;) .Select(c => new { c.Name, c.Phone });
C# 3.0 Language Innovations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],var x = 5; static void Dump(this object o); c => c.Name new Point { x = 1, y = 2 } new { c.Name, c.Phone } from … where … select Expression<T>
Standard Query Operators GroupBy Grouping Any, All Quantifiers ToArray, ToList, ToDictionary Conversion Count, Sum, Min, Max, Average Aggregation First, FirstOrDefault, ElementAt Elements OfType<T> Casting Distinct, Union, Intersect, Except Sets Take, Skip, TakeWhile, SkipWhile Partitioning OrderBy, ThenBy Ordering Select, SelectMany Projection Where Restriction
Deferred Query Execution Customer[] custs = SampleData.GetCustomers(); var query = from c in custs where c.City == &quot;London&quot; select c.Name; var query = custs.Where(c => c.City == &quot;London&quot;).Select(c => c.Name); string[] names = query.ToArray(); custs Phone Name ID Select c => c.Name names c => c.City == &quot;London&quot; Where
DLinq For Relational Data SqlConnection c = new SqlConnection(…); c.Open(); SqlCommand cmd = new SqlCommand( @&quot;SELECT c.Name, c.Phone FROM Customers c WHERE c.City = @p0&quot;); cmd.Parameters.AddWithValue(&quot;@p0&quot;, &quot;London“); DataReader dr = c.Execute(cmd); while (dr.Read()) { string name = dr.GetString(0); string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2); } dr.Close(); Accessing data today Queries in quotes Loosely bound arguments Loosely typed result sets No compile time checks
DLinq For Relational Data public class Customer { … } public class Northwind: DataContext { public Table<Customer> Customers; … } Northwind db = new Northwind(…); var contacts = from c in db.Customers where c.City == &quot;London&quot; select new { c.Name, c.Phone }; Accessing data with DLinq Classes describe data Strongly typed connection Integrated query syntax Strongly typed results Tables are like collections
DLinq For Relational Data ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XLinq For XML Data XmlDocument doc = new XmlDocument(); XmlElement contacts = doc.CreateElement(&quot;contacts&quot;); foreach (Customer c in customers) if (c.Country == &quot;USA&quot;) { XmlElement e = doc.CreateElement(&quot;contact&quot;); XmlElement name = doc.CreateElement(&quot;name&quot;); name.InnerText = c.CompanyName; e.AppendChild(name); XmlElement phone = doc.CreateElement(&quot;phone&quot;); phone.InnerText = c.Phone; e.AppendChild(phone); contacts.AppendChild(e); } doc.AppendChild(contacts); Programming XML today <contacts> <contact> <name>Great Lakes Food</name> <phone>(503) 555-7123</phone> </contact> … </contacts> Imperative model Document centric No integrated queries Memory intensive
XLinq For XML Data XElement contacts = new XElement(&quot;contacts&quot;, from c in customers where c.Country == &quot;USA&quot; select new XElement(&quot;contact&quot;, new XElement(&quot;name&quot;, c.CompanyName), new XElement(&quot;phone&quot;, c.Phone) ) ); Programming XML with XLinq Declarative model Element centric Integrated queries Smaller and faster
XLinq For XML Data ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The LINQ Project ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Benefits Of LINQ ,[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6rohassanie
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservationSwarup Kumar Boro
 
Javascript built in String Functions
Javascript built in String FunctionsJavascript built in String Functions
Javascript built in String FunctionsAvanitrambadiya
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...ssuserd6b1fd
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperDeepak Singh
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_iNico Ludwig
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
Thinking in object oriented - Part 2
Thinking in object oriented - Part 2Thinking in object oriented - Part 2
Thinking in object oriented - Part 2Reza Taroosheh
 
Coding Guidelines - Crafting Clean Code
Coding Guidelines - Crafting Clean CodeCoding Guidelines - Crafting Clean Code
Coding Guidelines - Crafting Clean CodeGanesh Samarthyam
 

What's hot (20)

FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
Javascript built in String Functions
Javascript built in String FunctionsJavascript built in String Functions
Javascript built in String Functions
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
Ch 4
Ch 4Ch 4
Ch 4
 
C++ Pointers
C++ PointersC++ Pointers
C++ Pointers
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Thinking in object oriented - Part 2
Thinking in object oriented - Part 2Thinking in object oriented - Part 2
Thinking in object oriented - Part 2
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
New C# features
New C# featuresNew C# features
New C# features
 
Coding Guidelines - Crafting Clean Code
Coding Guidelines - Crafting Clean CodeCoding Guidelines - Crafting Clean Code
Coding Guidelines - Crafting Clean Code
 
Php
PhpPhp
Php
 
C++ Template
C++ TemplateC++ Template
C++ Template
 
Pointers
PointersPointers
Pointers
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 

Viewers also liked

Linq E Ef 1207668728621762 9
Linq E Ef 1207668728621762 9Linq E Ef 1207668728621762 9
Linq E Ef 1207668728621762 9google
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 
Linq 1207579553462901 8
Linq 1207579553462901 8Linq 1207579553462901 8
Linq 1207579553462901 8google
 
Introduccion A Linq 1205779028184546 5
Introduccion A Linq 1205779028184546 5Introduccion A Linq 1205779028184546 5
Introduccion A Linq 1205779028184546 5google
 
Linq To Sql 1221970293242272 9
Linq To Sql 1221970293242272 9Linq To Sql 1221970293242272 9
Linq To Sql 1221970293242272 9google
 
Rolling Linq Wcf Silverlight Old4830
Rolling Linq Wcf Silverlight Old4830Rolling Linq Wcf Silverlight Old4830
Rolling Linq Wcf Silverlight Old4830google
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01google
 
Introduccion a LINQ
Introduccion a LINQIntroduccion a LINQ
Introduccion a LINQTonymx
 

Viewers also liked (10)

Linq E Ef 1207668728621762 9
Linq E Ef 1207668728621762 9Linq E Ef 1207668728621762 9
Linq E Ef 1207668728621762 9
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
Linq 1207579553462901 8
Linq 1207579553462901 8Linq 1207579553462901 8
Linq 1207579553462901 8
 
Introduccion A Linq 1205779028184546 5
Introduccion A Linq 1205779028184546 5Introduccion A Linq 1205779028184546 5
Introduccion A Linq 1205779028184546 5
 
Linq To Sql 1221970293242272 9
Linq To Sql 1221970293242272 9Linq To Sql 1221970293242272 9
Linq To Sql 1221970293242272 9
 
Rolling Linq Wcf Silverlight Old4830
Rolling Linq Wcf Silverlight Old4830Rolling Linq Wcf Silverlight Old4830
Rolling Linq Wcf Silverlight Old4830
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01
 
Cloud computing: highlights
Cloud computing: highlightsCloud computing: highlights
Cloud computing: highlights
 
Linq
LinqLinq
Linq
 
Introduccion a LINQ
Introduccion a LINQIntroduccion a LINQ
Introduccion a LINQ
 

Similar to Linq 090701233237 Phpapp01

Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05CHOOSE
 
Linq Sanjay Vyas
Linq   Sanjay VyasLinq   Sanjay Vyas
Linq Sanjay Vyasrsnarayanan
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaJevgeni Kabanov
 
Share pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShare pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShakir Majeed Khan
 
Microsoft Ado
Microsoft AdoMicrosoft Ado
Microsoft Adooswchavez
 
Web Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The ClientWeb Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The Clientgrutz
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008Luis Enrique
 
Language Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperLanguage Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperNyros Technologies
 
Introduction to Event Sourcing and CQRS
Introduction to Event Sourcing and CQRSIntroduction to Event Sourcing and CQRS
Introduction to Event Sourcing and CQRSVladik Khononov
 

Similar to Linq 090701233237 Phpapp01 (20)

Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
 
Introducción a LINQ
Introducción a LINQIntroducción a LINQ
Introducción a LINQ
 
Linq Sanjay Vyas
Linq   Sanjay VyasLinq   Sanjay Vyas
Linq Sanjay Vyas
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
 
PostThis
PostThisPostThis
PostThis
 
Share pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShare pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbs
 
Introduction to Linq
Introduction to LinqIntroduction to Linq
Introduction to Linq
 
Linq intro
Linq introLinq intro
Linq intro
 
Greg Demo Slides
Greg Demo SlidesGreg Demo Slides
Greg Demo Slides
 
Jenny Donnelly
Jenny DonnellyJenny Donnelly
Jenny Donnelly
 
Microsoft Ado
Microsoft AdoMicrosoft Ado
Microsoft Ado
 
Web Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The ClientWeb Security Mistakes: Trusting The Client
Web Security Mistakes: Trusting The Client
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
Linq
LinqLinq
Linq
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
Language Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperLanguage Integrated Query By Nyros Developer
Language Integrated Query By Nyros Developer
 
Drools BeJUG 2010
Drools BeJUG 2010Drools BeJUG 2010
Drools BeJUG 2010
 
Introduction to Event Sourcing and CQRS
Introduction to Event Sourcing and CQRSIntroduction to Event Sourcing and CQRS
Introduction to Event Sourcing and CQRS
 

Recently uploaded

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Linq 090701233237 Phpapp01

  • 1. The LINQ Project Standard Query Operators DLinq (ADO.NET) XLinq (System.Xml) .NET Language Integrated Query C# VB Others… Objects <book> <title/> <author/> <year/> <price/> </book> XML SQL WinFS
  • 3.
  • 4. C# 3.0 Language Innovations var contacts = from c in customers where c.State == &quot;WA&quot; select new { c.Name, c.Phone }; var contacts = customers .Where(c => c.State == &quot;WA&quot;) .Select(c => new { c.Name, c.Phone }); Extension methods Lambda expressions Query expressions Object initializers Anonymous types Local variable type inference
  • 5. Lambda Expressions and Extension Methods
  • 6. Object Initializers public class Rectangle { private Point p1 = new Point(); private Point p2 = new Point(); public Point P1 { get { return p1; } } public Point P2 { get { return p2; } } } Rectangle r = new Rectangle { P1 = { X = 0, Y = 1 }, P2 = { X = 2, Y = 3 } }; Rectangle r = new Rectangle(); r.P1.X = 0; r.P1.Y = 1; r.P2.X = 2; r.P2.Y = 3; Embedded objects No “new Point” Read-only properties
  • 7. Local Variable Type Inference int i = 5; string s = &quot;Hello&quot;; double d = 1.0; int[] numbers = new int[] {1, 2, 3}; Dictionary<int,Order> orders = new Dictionary<int,Order>(); var i = 5; var s = &quot;Hello&quot;; var d = 1.0; var numbers = new int[] {1, 2, 3}; var orders = new Dictionary<int,Order>(); “ var” means same type as initializer
  • 8. Anonymous Types public class Customer { public string Name; public Address Address; public string Phone; public List<Order> Orders; … } public class Contact { public string Name; public string Phone; } Customer c = GetCustomer(…); Contact x = new Contact { Name = c.Name, Phone = c.Phone } ; Customer c = GetCustomer(…); var x = new { c.Name, c.Phone } ; Customer c = GetCustomer(…); var x = new { Name = c.Name, Phone = c.Phone } ; class ??? { public string Name; public string Phone; } Projection style initializer
  • 9.
  • 10.
  • 11.
  • 12. Standard Query Operators GroupBy Grouping Any, All Quantifiers ToArray, ToList, ToDictionary Conversion Count, Sum, Min, Max, Average Aggregation First, FirstOrDefault, ElementAt Elements OfType<T> Casting Distinct, Union, Intersect, Except Sets Take, Skip, TakeWhile, SkipWhile Partitioning OrderBy, ThenBy Ordering Select, SelectMany Projection Where Restriction
  • 13. Deferred Query Execution Customer[] custs = SampleData.GetCustomers(); var query = from c in custs where c.City == &quot;London&quot; select c.Name; var query = custs.Where(c => c.City == &quot;London&quot;).Select(c => c.Name); string[] names = query.ToArray(); custs Phone Name ID Select c => c.Name names c => c.City == &quot;London&quot; Where
  • 14. DLinq For Relational Data SqlConnection c = new SqlConnection(…); c.Open(); SqlCommand cmd = new SqlCommand( @&quot;SELECT c.Name, c.Phone FROM Customers c WHERE c.City = @p0&quot;); cmd.Parameters.AddWithValue(&quot;@p0&quot;, &quot;London“); DataReader dr = c.Execute(cmd); while (dr.Read()) { string name = dr.GetString(0); string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2); } dr.Close(); Accessing data today Queries in quotes Loosely bound arguments Loosely typed result sets No compile time checks
  • 15. DLinq For Relational Data public class Customer { … } public class Northwind: DataContext { public Table<Customer> Customers; … } Northwind db = new Northwind(…); var contacts = from c in db.Customers where c.City == &quot;London&quot; select new { c.Name, c.Phone }; Accessing data with DLinq Classes describe data Strongly typed connection Integrated query syntax Strongly typed results Tables are like collections
  • 16.
  • 17. XLinq For XML Data XmlDocument doc = new XmlDocument(); XmlElement contacts = doc.CreateElement(&quot;contacts&quot;); foreach (Customer c in customers) if (c.Country == &quot;USA&quot;) { XmlElement e = doc.CreateElement(&quot;contact&quot;); XmlElement name = doc.CreateElement(&quot;name&quot;); name.InnerText = c.CompanyName; e.AppendChild(name); XmlElement phone = doc.CreateElement(&quot;phone&quot;); phone.InnerText = c.Phone; e.AppendChild(phone); contacts.AppendChild(e); } doc.AppendChild(contacts); Programming XML today <contacts> <contact> <name>Great Lakes Food</name> <phone>(503) 555-7123</phone> </contact> … </contacts> Imperative model Document centric No integrated queries Memory intensive
  • 18. XLinq For XML Data XElement contacts = new XElement(&quot;contacts&quot;, from c in customers where c.Country == &quot;USA&quot; select new XElement(&quot;contact&quot;, new XElement(&quot;name&quot;, c.CompanyName), new XElement(&quot;phone&quot;, c.Phone) ) ); Programming XML with XLinq Declarative model Element centric Integrated queries Smaller and faster
  • 19.
  • 20.
  • 21.