SlideShare uma empresa Scribd logo
1 de 12
LINQ
(Language Integrated Query)
for absolute beginner
Vasistan Shakkaravarthi
1
Introduction
• A query is an expression that retrieves data from a data source.
• Queries are usually expressed in a specialized query language.
• Different languages have been developed over time for the various
types of data sources,
for example
• SQL for relational databases
• XQuery for XML.
2LINQ for absolute beginners
LINQ
Operators
Projection
Restriction
Grouping
Set
Conversion
Partitioning
OrderingElement
Generation
Quantifiers
Aggregate
Miscellaneous
Join
3
Frequently used Operators
Projection
Select
Select Many
Restriction
Where
Grouping
GroupBy
Aggregate
Sum
Count
Min
Max
Average
Ordering
OrderBy
OrderByDescending
ThenBy
ThenByDescending
Reverse
4LINQ for absolute beginners
Steps involved in LINQ operation
Obtain the
Data Source
Create
Query
Execute
5LINQ for absolute beginners
Sample data source
EmpID EmpName Gender Age ShortCode
1 Kathirvel M 26 KV
2 Vivian M 27 OV
3 Veeramanai M 25 AV
4 Kalpana F 26 KL
5 Kavitha F 25 KS
6 Vasi M 28 SV
7 Kamalam F 28 KL
8 Sudha F 27 SS
9 Kumaraguru M 28 KG
6LINQ for absolute beginners
Projection Operator
SELECT e.EmpName FROM EmployeeInfo e
from e in EmployeeInfo select e.EmpName
SQL
LINQ Select
SELECT e.EmpName, e.Age FROM EmployeeInfo e
from e in EmployeeInfo
select new {EmpName = e.EmpName, Age = e.Age }
SQL
LINQ
SelectMany
EmpName
Kathirvel
Vivian
Veeramanai
Kalpana
Kavitha
Vasi
Kamalam
Sudha
Kumaraguru
EmpName Age
Kathirvel 26
Vivian 27
Veeramanai 25
Kalpana 26
Kavitha 25
Vasi 28
Kamalam 28
Sudha 27
Kumaraguru 28
7LINQ for absolute beginners
Restriction Operators
SELECT e.EmpName FROM EmployeeInfo e
WHERE e.Gender = ‘M’
from e in EmployeeInfo
where e.Gender == ‘M’
select e.EmpName
SQL
LINQ
Where
EmpName
Kathirvel
Vivian
Veeramanai
Vasi
Kumaraguru
8LINQ for absolute beginners
Grouping/Aggregate Operators
SELECT e.Gender, Count(e.*) as Employees FROM EmployeeInfo e
GROUP BY e.Gender
from e in EmployeeInfo
group e by e.Gender into grp
select new {Gender = e.Key, Employees = grp.Count()}
SQL
LINQ Grouping/
Aggregation
Gender Employees
F 4
M 5
9LINQ for absolute beginners
Ordering Operators
SELECT e.EmpName FROM EmployeeInfo e
ORDER BY e.EmpName
from e in EmployeeInfo
orderby e.EmpName
select e.EmpName
SQL
LINQ
OrderBy
10LINQ for absolute beginners
EmpName
Kalpana
Kamalam
Kathirvel
Kavitha
Kumaraguru
Sudha
Vasi
Veeramanai
Vivian
from e in EmployeeInfo
orderby e.EmpName descending
select e.EmpName OrderByDescending
EmpName
Vivian
Veeramanai
Vasi
Sudha
Kumaraguru
Kavitha
Kathirvel
Kamalam
Kalpana
Query Execution Types
• Simple query for further operation
Deferred Query
• Query that involves aggregate functions
Immediate Query
LINQ for absolute beginners 11
Thank you
Check the other resources
Blog
http://vasistan.blogspot.in
YouTube
http://www.youtube.com/playlist?list=PL-CcORxeaUcgXHO7UW9sGNbue9wH-4No3

Mais conteúdo relacionado

Semelhante a LINQ for absolute beginners

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
 
SoDA v2 - Named Entity Recognition from streaming text
SoDA v2 - Named Entity Recognition from streaming textSoDA v2 - Named Entity Recognition from streaming text
SoDA v2 - Named Entity Recognition from streaming textSujit Pal
 
Understanding LINQ in C#
Understanding LINQ in C# Understanding LINQ in C#
Understanding LINQ in C# MD. Shohag Mia
 
Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2asim78
 
Powering an API with GraphQL, Golang, and NoSQL
Powering an API with GraphQL, Golang, and NoSQLPowering an API with GraphQL, Golang, and NoSQL
Powering an API with GraphQL, Golang, and NoSQLNic Raboy
 
Illuminating Lucene.Net
Illuminating Lucene.NetIlluminating Lucene.Net
Illuminating Lucene.NetDean Thrasher
 
Евгений Бобров "Powered by OSS. Масштабируемая потоковая обработка и анализ б...
Евгений Бобров "Powered by OSS. Масштабируемая потоковая обработка и анализ б...Евгений Бобров "Powered by OSS. Масштабируемая потоковая обработка и анализ б...
Евгений Бобров "Powered by OSS. Масштабируемая потоковая обработка и анализ б...Fwdays
 
Introduction to Lucene and Solr - 1
Introduction to Lucene and Solr - 1Introduction to Lucene and Solr - 1
Introduction to Lucene and Solr - 1YI-CHING WU
 
Data Designed for Discovery
Data Designed for DiscoveryData Designed for Discovery
Data Designed for DiscoveryOCLC
 
Is there a SQL for NoSQL?
Is there a SQL for NoSQL?Is there a SQL for NoSQL?
Is there a SQL for NoSQL?Arthur Keen
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrErik Hatcher
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 

Semelhante a LINQ for absolute beginners (15)

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
 
SoDA v2 - Named Entity Recognition from streaming text
SoDA v2 - Named Entity Recognition from streaming textSoDA v2 - Named Entity Recognition from streaming text
SoDA v2 - Named Entity Recognition from streaming text
 
Understanding LINQ in C#
Understanding LINQ in C# Understanding LINQ in C#
Understanding LINQ in C#
 
Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2
 
Powering an API with GraphQL, Golang, and NoSQL
Powering an API with GraphQL, Golang, and NoSQLPowering an API with GraphQL, Golang, and NoSQL
Powering an API with GraphQL, Golang, and NoSQL
 
Linq
LinqLinq
Linq
 
Illuminating Lucene.Net
Illuminating Lucene.NetIlluminating Lucene.Net
Illuminating Lucene.Net
 
Евгений Бобров "Powered by OSS. Масштабируемая потоковая обработка и анализ б...
Евгений Бобров "Powered by OSS. Масштабируемая потоковая обработка и анализ б...Евгений Бобров "Powered by OSS. Масштабируемая потоковая обработка и анализ б...
Евгений Бобров "Powered by OSS. Масштабируемая потоковая обработка и анализ б...
 
LINQ in C#
LINQ in C#LINQ in C#
LINQ in C#
 
Introduction to Lucene and Solr - 1
Introduction to Lucene and Solr - 1Introduction to Lucene and Solr - 1
Introduction to Lucene and Solr - 1
 
LINQ PPT.pptx
LINQ PPT.pptxLINQ PPT.pptx
LINQ PPT.pptx
 
Data Designed for Discovery
Data Designed for DiscoveryData Designed for Discovery
Data Designed for Discovery
 
Is there a SQL for NoSQL?
Is there a SQL for NoSQL?Is there a SQL for NoSQL?
Is there a SQL for NoSQL?
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 

Último

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

LINQ for absolute beginners

  • 1. LINQ (Language Integrated Query) for absolute beginner Vasistan Shakkaravarthi 1
  • 2. Introduction • A query is an expression that retrieves data from a data source. • Queries are usually expressed in a specialized query language. • Different languages have been developed over time for the various types of data sources, for example • SQL for relational databases • XQuery for XML. 2LINQ for absolute beginners
  • 4. Frequently used Operators Projection Select Select Many Restriction Where Grouping GroupBy Aggregate Sum Count Min Max Average Ordering OrderBy OrderByDescending ThenBy ThenByDescending Reverse 4LINQ for absolute beginners
  • 5. Steps involved in LINQ operation Obtain the Data Source Create Query Execute 5LINQ for absolute beginners
  • 6. Sample data source EmpID EmpName Gender Age ShortCode 1 Kathirvel M 26 KV 2 Vivian M 27 OV 3 Veeramanai M 25 AV 4 Kalpana F 26 KL 5 Kavitha F 25 KS 6 Vasi M 28 SV 7 Kamalam F 28 KL 8 Sudha F 27 SS 9 Kumaraguru M 28 KG 6LINQ for absolute beginners
  • 7. Projection Operator SELECT e.EmpName FROM EmployeeInfo e from e in EmployeeInfo select e.EmpName SQL LINQ Select SELECT e.EmpName, e.Age FROM EmployeeInfo e from e in EmployeeInfo select new {EmpName = e.EmpName, Age = e.Age } SQL LINQ SelectMany EmpName Kathirvel Vivian Veeramanai Kalpana Kavitha Vasi Kamalam Sudha Kumaraguru EmpName Age Kathirvel 26 Vivian 27 Veeramanai 25 Kalpana 26 Kavitha 25 Vasi 28 Kamalam 28 Sudha 27 Kumaraguru 28 7LINQ for absolute beginners
  • 8. Restriction Operators SELECT e.EmpName FROM EmployeeInfo e WHERE e.Gender = ‘M’ from e in EmployeeInfo where e.Gender == ‘M’ select e.EmpName SQL LINQ Where EmpName Kathirvel Vivian Veeramanai Vasi Kumaraguru 8LINQ for absolute beginners
  • 9. Grouping/Aggregate Operators SELECT e.Gender, Count(e.*) as Employees FROM EmployeeInfo e GROUP BY e.Gender from e in EmployeeInfo group e by e.Gender into grp select new {Gender = e.Key, Employees = grp.Count()} SQL LINQ Grouping/ Aggregation Gender Employees F 4 M 5 9LINQ for absolute beginners
  • 10. Ordering Operators SELECT e.EmpName FROM EmployeeInfo e ORDER BY e.EmpName from e in EmployeeInfo orderby e.EmpName select e.EmpName SQL LINQ OrderBy 10LINQ for absolute beginners EmpName Kalpana Kamalam Kathirvel Kavitha Kumaraguru Sudha Vasi Veeramanai Vivian from e in EmployeeInfo orderby e.EmpName descending select e.EmpName OrderByDescending EmpName Vivian Veeramanai Vasi Sudha Kumaraguru Kavitha Kathirvel Kamalam Kalpana
  • 11. Query Execution Types • Simple query for further operation Deferred Query • Query that involves aggregate functions Immediate Query LINQ for absolute beginners 11
  • 12. Thank you Check the other resources Blog http://vasistan.blogspot.in YouTube http://www.youtube.com/playlist?list=PL-CcORxeaUcgXHO7UW9sGNbue9wH-4No3