SlideShare a Scribd company logo
7
Most read
10
Most read
13
Most read
Understanding LINQLINQ in C#
MD. Shohag Mia
mdshohagmia14@outlook.com
.NET Trainee at LICT Project, World Bank
Index
• Introduction to LINQ
• Why should we use LINQ?
• LINQ architecture
• Lambda Expression
• Getting started with standard query operators
• LINQ to objects
• Getting started with LINQ to SQL integration
Introduction to LINQ
• LINQ stands for Language Integrated Query
• A query is an expression that retrieves data from a data source or database.
• Retrieve data from different data source like an object collection, sql server
database, xml & web service etc.
• Syntax like- var students = dbContext.Students.ToList();
Why should we use LINQ?
LINQ enables us to work with different data sources using similar types of code
styles like SQL Database, XML Documents and in-memory objects.
Another benefit of using LINQ is that it provides intellisense and compile time
error checking .
Advantage
• Quick turn around for development
• Queries can be dynamically generated
• Tables are automatically created into class
• Columns are automatically created into properties
• Relationship are automatically appeaded to classes
• Lambda expressions are awesome
• Data is easy to setup and use
• Easy debugging & transformation (SQL Data to XML Data)
Limitations
• There is an overhead for creating queries
• Small data sets will take longer to build the query than execute
• Table joins are very slow
• Hard to understand advance queries using Expressions
LINQ Architecture
Lambda Expression
C# 3.0(.NET 3.5) introduced the lambda expression along with LINQ. In C# a lambda is a function that
uses clear and short syntax like Parameters => Expression
Example: var customers = dbContext.Customers.Where(c => c.City == "London");
There are over 50 standard query operators available in LINQ that provide different functionalities like
filtering, sorting, grouping, aggregation, concatenation, etc.
Getting started with standard query operators
Standard Query Operators in Query Syntax
Three Parts of a Query Operation
LINQ to Object
• Native query syntax in C# , VB etc with IntelliSence Autocompletion.
• Query operator can be used against any .net collection (Innumerable<T>) such as Select, Where,
GroupBy, Join etc.
• Lamda Expression.
Getting started with LINQ to SQL integration
LINQ to SQL offers an infrastructure (run-time) for the management of relational data as objects. It is a
component of version 3.5 of the .NET Framework and ably does the translation of language-integrated
queries of the object model into SQL.
Example
Resources
• https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/getting-started-with-
linq
• https://msdn.microsoft.com/en-us/library/bb308959.aspx
• https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/linq/
Any Question?
☺☺☺
♥♥♥Happy Coding♥♥♥

More Related Content

What's hot (20)

PPTX
Java swing
Apurbo Datta
 
PPT
JDBC Tutorial
Information Technology
 
PPT
Collection Framework in java
CPD INDIA
 
PPTX
Advance Java Topics (J2EE)
slire
 
PPT
Java collections concept
kumar gaurav
 
PPTX
Hibernate ppt
Aneega
 
PPTX
Exceptions in Java
Vadym Lotar
 
PPT
Resource Bundle
Sunil OS
 
PPTX
Java Logging
Zeeshan Bilal
 
PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
PPT
ADO.NET Entity Framework
Doncho Minkov
 
PPT
Servlets
Sasidhar Kothuru
 
PPTX
C sharp
sanjay joshi
 
PPT
ADO .Net
DrSonali Vyas
 
PPTX
JDBC - JPA - Spring Data
Arturs Drozdovs
 
PPT
Introduction to .NET Framework
Raghuveer Guthikonda
 
PPTX
Data structure and algorithm using java
Narayan Sau
 
PPTX
Core java complete ppt(note)
arvind pandey
 
Java swing
Apurbo Datta
 
JDBC Tutorial
Information Technology
 
Collection Framework in java
CPD INDIA
 
Advance Java Topics (J2EE)
slire
 
Java collections concept
kumar gaurav
 
Hibernate ppt
Aneega
 
Exceptions in Java
Vadym Lotar
 
Resource Bundle
Sunil OS
 
Java Logging
Zeeshan Bilal
 
JDBC: java DataBase connectivity
Tanmoy Barman
 
ADO.NET Entity Framework
Doncho Minkov
 
C sharp
sanjay joshi
 
ADO .Net
DrSonali Vyas
 
JDBC - JPA - Spring Data
Arturs Drozdovs
 
Introduction to .NET Framework
Raghuveer Guthikonda
 
Data structure and algorithm using java
Narayan Sau
 
Core java complete ppt(note)
arvind pandey
 

Similar to Understanding LINQ in C# (20)

PDF
Asp.Net 3.5 Part 2
asim78
 
PPTX
SQL ttrain wrwrwrw wwrw wwrrrwrwrwrwwrwr.pptx
antony194610
 
PPTX
LINQ PPT.pptx
09AnkitkumarJhariya
 
DOCX
Linq in C#
Umar Farooq
 
PPTX
Asp.net c# mvc Training-Day-5 of Day-9
AHM Pervej Kabir
 
PPTX
Link quries
ulfat mushtaq
 
PPTX
Asp.net
BALUJAINSTITUTE
 
PPTX
Iterator - a powerful but underappreciated design pattern
Nitin Bhide
 
PPT
C# 3.0 and LINQ Tech Talk
Michael Heydt
 
PDF
New c sharp3_features_(linq)_part_iv
Nico Ludwig
 
PPTX
C# advanced topics and future - C#5
Peter Gfader
 
PPT
MySQL, LINQ and the ADO_NET Entity Framework Presentation.ppt
hammadali341730
 
PDF
70487.pdf
Karen Benoit
 
PPT
Linq
ClickExpo
 
PPTX
ORM - Ivan Marković
Software StartUp Academy Osijek
 
DOCX
Project_Report (BARC-Jerin)_final
Jerin John
 
PDF
The View - Leveraging Lotuscript for Database Connectivity
Bill Buchan
 
PPT
LINQ-Introduction.ppt
ssusera8c91a
 
PDF
Dev buchan leveraging
Bill Buchan
 
Asp.Net 3.5 Part 2
asim78
 
SQL ttrain wrwrwrw wwrw wwrrrwrwrwrwwrwr.pptx
antony194610
 
LINQ PPT.pptx
09AnkitkumarJhariya
 
Linq in C#
Umar Farooq
 
Asp.net c# mvc Training-Day-5 of Day-9
AHM Pervej Kabir
 
Link quries
ulfat mushtaq
 
Iterator - a powerful but underappreciated design pattern
Nitin Bhide
 
C# 3.0 and LINQ Tech Talk
Michael Heydt
 
New c sharp3_features_(linq)_part_iv
Nico Ludwig
 
C# advanced topics and future - C#5
Peter Gfader
 
MySQL, LINQ and the ADO_NET Entity Framework Presentation.ppt
hammadali341730
 
70487.pdf
Karen Benoit
 
Linq
ClickExpo
 
ORM - Ivan Marković
Software StartUp Academy Osijek
 
Project_Report (BARC-Jerin)_final
Jerin John
 
The View - Leveraging Lotuscript for Database Connectivity
Bill Buchan
 
LINQ-Introduction.ppt
ssusera8c91a
 
Dev buchan leveraging
Bill Buchan
 
Ad

Recently uploaded (20)

PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Ad

Understanding LINQ in C#