SlideShare a Scribd company logo
1 of 14
LINQ, DLINQ and XLINQ Ajeet Kumar C# 3.0
What is LINQ? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Philosophy of C# 3.0 And LINQ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Problem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],LINQ seeks to bridge the gap
What is LINQ? 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
Standard Query Operators Restriction Where Projection Select, SelectMany Ordering OrderBy, ThenBy Grouping GroupBy Quantifiers Any, All Partitioning Take, Skip, TakeWhile, SkipWhile Sets Distinct, Union, Intersect, Except Elements First, FirstOrDefault, ElementAt Aggregation Count, Sum, Min, Max, Average Conversion ToArray, ToList, ToDictionary Casting OfType<T>
DLinq ,[object Object],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 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 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XLinq 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 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 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is LINQ? ,[object Object],[object Object],[object Object],[object Object],[object Object],[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

Viewers also liked

Effectiveness of Simulated Experience in teaching Social Skills to children w...
Effectiveness of Simulated Experience in teaching Social Skills to children w...Effectiveness of Simulated Experience in teaching Social Skills to children w...
Effectiveness of Simulated Experience in teaching Social Skills to children w...Amanda Goh
 
Good Enough Prototype (Ivan Pashko Product Stream)
Good Enough Prototype (Ivan Pashko Product Stream)Good Enough Prototype (Ivan Pashko Product Stream)
Good Enough Prototype (Ivan Pashko Product Stream)IT Arena
 
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgºSierra Francisco Justo
 
Math (Summer 2016) CHD 120
Math (Summer 2016) CHD 120Math (Summer 2016) CHD 120
Math (Summer 2016) CHD 120jeh20717
 
One single motion presentation
One single motion presentationOne single motion presentation
One single motion presentationBMHnl
 
The future of engineering education
The future of engineering educationThe future of engineering education
The future of engineering educationDesign Concepts
 
SSIS coding conventions, best practices, tips and programming guidelines for ...
SSIS coding conventions, best practices, tips and programming guidelines for ...SSIS coding conventions, best practices, tips and programming guidelines for ...
SSIS coding conventions, best practices, tips and programming guidelines for ...Vishal Pawar
 
Fascinate with SQL SSIS Parallel processing
Fascinate with SQL SSIS Parallel processing Fascinate with SQL SSIS Parallel processing
Fascinate with SQL SSIS Parallel processing Vishal Pawar
 
Концептуальні засади реформування сфери інтелектуальної власності та її роль...
Концептуальні засади реформування  сфери інтелектуальної власності та її роль...Концептуальні засади реформування  сфери інтелектуальної власності та її роль...
Концептуальні засади реформування сфери інтелектуальної власності та її роль...Constantine Zerov
 
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)IT Arena
 
Improving handwriting and concentration - Tips and tricks for teachers!
Improving handwriting and concentration - Tips and tricks for teachers!Improving handwriting and concentration - Tips and tricks for teachers!
Improving handwriting and concentration - Tips and tricks for teachers!Nathan Varma
 
Calivita int. quality life (german)
Calivita int. quality life (german)Calivita int. quality life (german)
Calivita int. quality life (german)Zoran Stojcevski
 

Viewers also liked (18)

Tl first group brochure
Tl first group brochureTl first group brochure
Tl first group brochure
 
Art
ArtArt
Art
 
Effectiveness of Simulated Experience in teaching Social Skills to children w...
Effectiveness of Simulated Experience in teaching Social Skills to children w...Effectiveness of Simulated Experience in teaching Social Skills to children w...
Effectiveness of Simulated Experience in teaching Social Skills to children w...
 
Good Enough Prototype (Ivan Pashko Product Stream)
Good Enough Prototype (Ivan Pashko Product Stream)Good Enough Prototype (Ivan Pashko Product Stream)
Good Enough Prototype (Ivan Pashko Product Stream)
 
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº
14 albrieu&amp;baruzzi 2016 xviica vyt comparaciónnormasdºgº
 
Math (Summer 2016) CHD 120
Math (Summer 2016) CHD 120Math (Summer 2016) CHD 120
Math (Summer 2016) CHD 120
 
SQL SoloLearn
SQL SoloLearnSQL SoloLearn
SQL SoloLearn
 
Lemon oil test
Lemon oil testLemon oil test
Lemon oil test
 
Surih bentuk
Surih bentukSurih bentuk
Surih bentuk
 
One single motion presentation
One single motion presentationOne single motion presentation
One single motion presentation
 
The future of engineering education
The future of engineering educationThe future of engineering education
The future of engineering education
 
New tsql features
New tsql featuresNew tsql features
New tsql features
 
SSIS coding conventions, best practices, tips and programming guidelines for ...
SSIS coding conventions, best practices, tips and programming guidelines for ...SSIS coding conventions, best practices, tips and programming guidelines for ...
SSIS coding conventions, best practices, tips and programming guidelines for ...
 
Fascinate with SQL SSIS Parallel processing
Fascinate with SQL SSIS Parallel processing Fascinate with SQL SSIS Parallel processing
Fascinate with SQL SSIS Parallel processing
 
Концептуальні засади реформування сфери інтелектуальної власності та її роль...
Концептуальні засади реформування  сфери інтелектуальної власності та її роль...Концептуальні засади реформування  сфери інтелектуальної власності та її роль...
Концептуальні засади реформування сфери інтелектуальної власності та її роль...
 
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)
Don’t Ask for Permission, Ask for Forgiveness (Thomas Schoerner Product Stream)
 
Improving handwriting and concentration - Tips and tricks for teachers!
Improving handwriting and concentration - Tips and tricks for teachers!Improving handwriting and concentration - Tips and tricks for teachers!
Improving handwriting and concentration - Tips and tricks for teachers!
 
Calivita int. quality life (german)
Calivita int. quality life (german)Calivita int. quality life (german)
Calivita int. quality life (german)
 

Similar to LINQ

Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01google
 
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
 
Share pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShare pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShakir Majeed Khan
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Codemotion
 
Language Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperLanguage Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperNyros Technologies
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008Luis Enrique
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationRandy Connolly
 
Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Tomas Petricek
 
Dev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManDev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManQuek Lilian
 
Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Paulo Gandra de Sousa
 
Data Access Mobile Devices
Data Access Mobile DevicesData Access Mobile Devices
Data Access Mobile Devicesvenkat987
 
Structured Document Search and Retrieval
Structured Document Search and RetrievalStructured Document Search and Retrieval
Structured Document Search and RetrievalOptum
 
Introduction To Flex
Introduction To FlexIntroduction To Flex
Introduction To FlexYoss Cohen
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01google
 
Microsoft Ado
Microsoft AdoMicrosoft Ado
Microsoft Adooswchavez
 
Itemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integrationItemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integration{item:foo}
 

Similar to LINQ (20)

Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
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-05
 
Share pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbsShare pointtechies linqtosp-andsbs
Share pointtechies linqtosp-andsbs
 
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
Perchè potresti aver bisogno di un database NoSQL anche se non sei Google o F...
 
Language Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperLanguage Integrated Query By Nyros Developer
Language Integrated Query By Nyros Developer
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
B_110500002
B_110500002B_110500002
B_110500002
 
Greg Demo Slides
Greg Demo SlidesGreg Demo Slides
Greg Demo Slides
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And Representation
 
Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#
 
Dev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming ManDev-In-Town:Linq To Sql by Chan Ming Man
Dev-In-Town:Linq To Sql by Chan Ming Man
 
Linq
LinqLinq
Linq
 
PoEAA by Example
PoEAA by ExamplePoEAA by Example
PoEAA by Example
 
Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)
 
Data Access Mobile Devices
Data Access Mobile DevicesData Access Mobile Devices
Data Access Mobile Devices
 
Structured Document Search and Retrieval
Structured Document Search and RetrievalStructured Document Search and Retrieval
Structured Document Search and Retrieval
 
Introduction To Flex
Introduction To FlexIntroduction To Flex
Introduction To Flex
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01
 
Microsoft Ado
Microsoft AdoMicrosoft Ado
Microsoft Ado
 
Itemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integrationItemscript, a specification for RESTful JSON integration
Itemscript, a specification for RESTful JSON integration
 

LINQ

  • 1. LINQ, DLINQ and XLINQ Ajeet Kumar C# 3.0
  • 2.
  • 3.
  • 4.
  • 5. What is LINQ? 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
  • 6. Standard Query Operators Restriction Where Projection Select, SelectMany Ordering OrderBy, ThenBy Grouping GroupBy Quantifiers Any, All Partitioning Take, Skip, TakeWhile, SkipWhile Sets Distinct, Union, Intersect, Except Elements First, FirstOrDefault, ElementAt Aggregation Count, Sum, Min, Max, Average Conversion ToArray, ToList, ToDictionary Casting OfType<T>
  • 7.
  • 8. DLinq 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
  • 9.
  • 10. XLinq 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
  • 11. XLinq 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
  • 12.
  • 13.
  • 14.