SlideShare a Scribd company logo
1 of 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

More Related Content

Similar to 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
 

Similar to 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
 

Recently uploaded

Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
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
 
🐬 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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 

Recently uploaded (20)

Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 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
 

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