SlideShare a Scribd company logo
Language Integrated Query in
.NET (LINQ)
LINQ
 What is LINQ?
 It is designed to work with all shapes and sizes
of different data and allow you to perform
Query, Set, and Transform operations on all
of it. Pretty much anything that implements
Enumerable is a target for LINQ. The basic
units of data in LINQ are sequences and
elements.
 A sequence is any object that implements
IEnumerable<T> and an element is each item in
the sequence
There are a variety of flavors of LINQ for
accessing and manipulating different data
sources.
 LINQ to Objects
 LINQ to DataSets
 LINQ to SQL
 LINQ to Entities
 LINQ to XML
Application
LINQ to SQL
SQL Server
from c in db.Customers
where c.City == "London"
select c.CompanyName
Enumerate
SELECT CompanyName
FROM Customer
WHERE City = 'London'
SQL Query
or SProc
Rows
Objects
db.Customers.Add(c1);
c2.City = “Seattle";
db.Customers.Remove(c3);
SubmitChanges()
INSERT INTO Customer …
UPDATE Customer …
DELETE FROM Customer …
DML
or SProcs
 In the Enumerable class in System.Linq, there are around
40 query operators—all implemented as static extension
methods. These are called standard query operators.
 Queries that operate over local sequences are called local
queries or LINQ-to-objects queries.
 LINQ also supports sequences that can be dynamically
fed from a remote data source such as a SQL Server.
These sequences additionally implement the
IQueryable<T>interface and are supported through a
matching set of standard query operators in the
Queryable class.
 A query is an expression that, when enumerated,
transforms sequences with query operators.
 The standard query operators provide query capabilities
including
› Filtering – where
› Projection – select, selectMany
› Aggregation – Sum, Max, Count, Average
› Sorting – orderby
› Grouping – groupby
› … and many more
 A query operator is a method that transforms a sequence.
 A typical query operator accepts an input sequence and emits a
transformed output sequence.
 Two sets of LINQ standard operators
› Operating on IEnumerable<T>
› Operating on IQueryable<T>
 LINQ makes heavy use of Generics.
Additionally, there were a number of features
added to the Visual Basic and C# languages
specifically to support LINQ.
 Type inference
 Extension Methods
 Object initializer
 Anonymous types
 Lambda expressions
 Query expressions
 All LINQ query operations consist of
three distinct actions:
› Obtain the data source
› Create the query
› Execute the query
 Fluent syntax is the most flexible and fundamental.
 To build more complex queries, you append additional query
operators to the expression, creating a chain.
 When query operators are chained as in this example, the output
sequence of one operator is the input sequence of the next.
 Delcare Variable with “var” keyword
 Compiler infers correct type
› Based on initialization
 Only for local, (non-null) initialized variables
Customer c = new Customer(“Bob”, “Smith”, 1234);
var c = new Customer(“Bob”, “Smith”, 1234);
var c; // No
var c = null; // No
var c = default(string); // Yes
public var DoThis(int x){} // No
public void DoThis(var x){} // No
Extension methods enable you to add methods to a
data type or interface from outside the definition.
This feature enables you to, in effect, add new
methods to an existing type without actually
modifying the type.
 Extends Existing Types
 Adds Methods Without Derivation
 Accesses Public Members of Extended Types
 Must be:
› public and static
› Housed within a static class
 Anonymous Methods
 The query operator evaluates your lambda
expression upon demand—typically once
per element in the input sequence.
 Lambda expressions allow you to feed your
own logic into the query operators.
 Example:
 C# provides a syntactic shortcut for writing
LINQ queries, called query expressions.
 At compile time, query syntax is converted into
method calls to a LINQ provider's
 Query expressions always start with a from
clause and end with either a select or group
clause.
 The from clause declares a range variable (in
this case, n), which you can think of as
traversing the input sequence—rather like
foreach
An important feature of most query operators is that
they execute not when constructed, but when
enumerated (in other words, when MoveNext is
called on its enumerator). Consider the following
query:
 Chaining Decorators
 Chaining query operators creates a
layering of decorators. Consider the
following query:
 All standard query operators provide deferred
execution, with the following exceptions:
› Operators that return a single element or scalar value,
such as First or Count
› The following conversion operators:
 ToArray, ToList, ToDictionary, ToLookup
 These operators cause immediate query execution
because their result types have no mechanism for
providing deferred execution. The Count method, for
instance, returns a simple integer, which doesn’t then
get enumerated. The following query is executed
immediately:
 If your query’s lambda expressions capture
outer variables, the query will honor the
value of the those variables at the time the
query runs:
 Familiar syntax for writing queries.
 Compile-time checking for syntax errors and
type safety.
 Improved debugger support.
 Powerful filtering, ordering, and grouping
capabilities.
 Consistent model for working with data
across various kinds of data sources and
formats.
 Subquery is a query contained within
another query’s lambda expression.
Link quries

More Related Content

What's hot

Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project Lambda
Rahman USTA
 
Apollo Server III
Apollo Server IIIApollo Server III
Apollo Server III
NodeXperts
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
Vraj Patel
 
Pure functions and usage in Angular
Pure functions and usage in AngularPure functions and usage in Angular
Pure functions and usage in Angular
MA Jiangfan
 
Introduction to RxJava on Android
Introduction to RxJava on AndroidIntroduction to RxJava on Android
Introduction to RxJava on Android
Chris Arriola
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
Marcus Denker
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
Anil Pokhrel
 
Functions and tasks in verilog
Functions and tasks in verilogFunctions and tasks in verilog
Functions and tasks in verilog
Nallapati Anindra
 
Dynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection PromisesDynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection Promises
Marcus Denker
 
Java 8 streams
Java 8 streams Java 8 streams
Java 8 streams
Srinivasan Raghvan
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
Jenish Patel
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
Marcus Denker
 
Lambdas HOL
Lambdas HOLLambdas HOL
Lambdas HOL
Oleg Tsal-Tsalko
 
Think in linq
Think in linqThink in linq
Think in linq
Sudipta Mukherjee
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
Learn By Watch
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
Marcus Denker
 
Functional programming in Javascript
Functional programming in JavascriptFunctional programming in Javascript
Functional programming in Javascript
Knoldus Inc.
 
Roslyn
RoslynRoslyn
LINQ in Visual Studio 2008
LINQ in Visual Studio 2008LINQ in Visual Studio 2008
LINQ in Visual Studio 2008
ukdpe
 
Sql Functions And Procedures
Sql Functions And ProceduresSql Functions And Procedures
Sql Functions And Procedures
DataminingTools Inc
 

What's hot (20)

Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project Lambda
 
Apollo Server III
Apollo Server IIIApollo Server III
Apollo Server III
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
Pure functions and usage in Angular
Pure functions and usage in AngularPure functions and usage in Angular
Pure functions and usage in Angular
 
Introduction to RxJava on Android
Introduction to RxJava on AndroidIntroduction to RxJava on Android
Introduction to RxJava on Android
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
Functions and tasks in verilog
Functions and tasks in verilogFunctions and tasks in verilog
Functions and tasks in verilog
 
Dynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection PromisesDynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection Promises
 
Java 8 streams
Java 8 streams Java 8 streams
Java 8 streams
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
Lambdas HOL
Lambdas HOLLambdas HOL
Lambdas HOL
 
Think in linq
Think in linqThink in linq
Think in linq
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
Functional programming in Javascript
Functional programming in JavascriptFunctional programming in Javascript
Functional programming in Javascript
 
Roslyn
RoslynRoslyn
Roslyn
 
LINQ in Visual Studio 2008
LINQ in Visual Studio 2008LINQ in Visual Studio 2008
LINQ in Visual Studio 2008
 
Sql Functions And Procedures
Sql Functions And ProceduresSql Functions And Procedures
Sql Functions And Procedures
 

Viewers also liked

Apuntes fisica 2
Apuntes fisica 2Apuntes fisica 2
Apuntes fisica 2
BrendaGutierrez98
 
Análisis económico de méxico andrea estrada buendía
Análisis económico de méxico  andrea estrada buendíaAnálisis económico de méxico  andrea estrada buendía
Análisis económico de méxico andrea estrada buendía
Andrea Zarai Estrada Buendia
 
Jason Zattler Wiser Insurance Agency
Jason Zattler Wiser Insurance AgencyJason Zattler Wiser Insurance Agency
Jason Zattler Wiser Insurance Agency
BNI
 
Windows 2003 sem suporte: por que você deveria se preocupar
Windows 2003 sem suporte: por que você deveria se preocuparWindows 2003 sem suporte: por que você deveria se preocupar
Windows 2003 sem suporte: por que você deveria se preocupar
Symantec Brasil
 
Primeros auxilios
Primeros auxiliosPrimeros auxilios
Primeros auxilios
Keyla Meriño
 
Metas brasileiras pós-2020
Metas brasileiras pós-2020Metas brasileiras pós-2020
Metas brasileiras pós-2020
Obsclima
 
Job satisfaction
Job satisfactionJob satisfaction
Job satisfaction
Vaidehi Thaker
 
Medical Termination of Pregnancy Act
Medical Termination of Pregnancy ActMedical Termination of Pregnancy Act
Medical Termination of Pregnancy Act
prajs9
 
Webgearing - Apple's AppStore
Webgearing -  Apple's AppStoreWebgearing -  Apple's AppStore
Webgearing - Apple's AppStore
Aberla
 
Job Satisfaction & Job Performance
Job Satisfaction & Job PerformanceJob Satisfaction & Job Performance
Job Satisfaction & Job Performance
hanaalaydrus
 

Viewers also liked (13)

Apuntes fisica 2
Apuntes fisica 2Apuntes fisica 2
Apuntes fisica 2
 
Análisis económico de méxico andrea estrada buendía
Análisis económico de méxico  andrea estrada buendíaAnálisis económico de méxico  andrea estrada buendía
Análisis económico de méxico andrea estrada buendía
 
Jason Zattler Wiser Insurance Agency
Jason Zattler Wiser Insurance AgencyJason Zattler Wiser Insurance Agency
Jason Zattler Wiser Insurance Agency
 
CV
CVCV
CV
 
Windows 2003 sem suporte: por que você deveria se preocupar
Windows 2003 sem suporte: por que você deveria se preocuparWindows 2003 sem suporte: por que você deveria se preocupar
Windows 2003 sem suporte: por que você deveria se preocupar
 
Triple S
Triple STriple S
Triple S
 
Primeros auxilios
Primeros auxiliosPrimeros auxilios
Primeros auxilios
 
CV_Per Morten Hoff
CV_Per Morten HoffCV_Per Morten Hoff
CV_Per Morten Hoff
 
Metas brasileiras pós-2020
Metas brasileiras pós-2020Metas brasileiras pós-2020
Metas brasileiras pós-2020
 
Job satisfaction
Job satisfactionJob satisfaction
Job satisfaction
 
Medical Termination of Pregnancy Act
Medical Termination of Pregnancy ActMedical Termination of Pregnancy Act
Medical Termination of Pregnancy Act
 
Webgearing - Apple's AppStore
Webgearing -  Apple's AppStoreWebgearing -  Apple's AppStore
Webgearing - Apple's AppStore
 
Job Satisfaction & Job Performance
Job Satisfaction & Job PerformanceJob Satisfaction & Job Performance
Job Satisfaction & Job Performance
 

Similar to Link quries

Linq in C#
Linq in C#Linq in C#
Linq in C#
Umar Farooq
 
Understanding LINQ in C#
Understanding LINQ in C# Understanding LINQ in C#
Understanding LINQ in C#
MD. Shohag Mia
 
LINQ.pptx
LINQ.pptxLINQ.pptx
LINQ.pptx
IrfanPinjari2
 
NHDay Introduction to LINQ2NH
NHDay Introduction to LINQ2NHNHDay Introduction to LINQ2NH
NHDay Introduction to LINQ2NH
Gian Maria Ricci
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
Nico Ludwig
 
LINQ in C#
LINQ in C#LINQ in C#
LINQ in C#
Basant Medhat
 
ORM - Ivan Marković
ORM - Ivan MarkovićORM - Ivan Marković
ORM - Ivan Marković
Software StartUp Academy Osijek
 
C# advanced topics and future - C#5
C# advanced topics and future - C#5C# advanced topics and future - C#5
C# advanced topics and future - C#5
Peter Gfader
 
LINQ PPT.pptx
LINQ PPT.pptxLINQ PPT.pptx
LINQ PPT.pptx
09AnkitkumarJhariya
 
LINQ-Introduction.ppt
LINQ-Introduction.pptLINQ-Introduction.ppt
LINQ-Introduction.ppt
ssusera8c91a
 
Linq in C# 3.0: An Overview
Linq in C# 3.0: An OverviewLinq in C# 3.0: An Overview
Linq in C# 3.0: An Overview
pradeepkothiyal
 
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
Quek Lilian
 
C#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New FeaturesC#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New Featurestechfreak
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01google
 
Module 3: Introduction to LINQ (Material)
Module 3: Introduction to LINQ (Material)Module 3: Introduction to LINQ (Material)
Module 3: Introduction to LINQ (Material)
Mohamed Saleh
 
Intake 37 linq2
Intake 37 linq2Intake 37 linq2
Intake 37 linq2
Mahmoud Ouf
 
LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1
ukdpe
 

Similar to Link quries (20)

Linq
LinqLinq
Linq
 
Linq in C#
Linq in C#Linq in C#
Linq in C#
 
Understanding LINQ in C#
Understanding LINQ in C# Understanding LINQ in C#
Understanding LINQ in C#
 
LINQ.pptx
LINQ.pptxLINQ.pptx
LINQ.pptx
 
B_110500002
B_110500002B_110500002
B_110500002
 
NHDay Introduction to LINQ2NH
NHDay Introduction to LINQ2NHNHDay Introduction to LINQ2NH
NHDay Introduction to LINQ2NH
 
New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
 
LINQ in C#
LINQ in C#LINQ in C#
LINQ in C#
 
ORM - Ivan Marković
ORM - Ivan MarkovićORM - Ivan Marković
ORM - Ivan Marković
 
C# advanced topics and future - C#5
C# advanced topics and future - C#5C# advanced topics and future - C#5
C# advanced topics and future - C#5
 
LINQ PPT.pptx
LINQ PPT.pptxLINQ PPT.pptx
LINQ PPT.pptx
 
LINQ-Introduction.ppt
LINQ-Introduction.pptLINQ-Introduction.ppt
LINQ-Introduction.ppt
 
Linq in C# 3.0: An Overview
Linq in C# 3.0: An OverviewLinq in C# 3.0: An Overview
Linq in C# 3.0: An Overview
 
Understanding linq
Understanding linqUnderstanding linq
Understanding linq
 
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
 
C#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New FeaturesC#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New Features
 
Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01Linqtosql 090629035715 Phpapp01
Linqtosql 090629035715 Phpapp01
 
Module 3: Introduction to LINQ (Material)
Module 3: Introduction to LINQ (Material)Module 3: Introduction to LINQ (Material)
Module 3: Introduction to LINQ (Material)
 
Intake 37 linq2
Intake 37 linq2Intake 37 linq2
Intake 37 linq2
 
LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1
 

Recently uploaded

DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
itech2017
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
ambekarshweta25
 

Recently uploaded (20)

DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
 

Link quries

  • 1.
  • 2. Language Integrated Query in .NET (LINQ)
  • 3. LINQ  What is LINQ?  It is designed to work with all shapes and sizes of different data and allow you to perform Query, Set, and Transform operations on all of it. Pretty much anything that implements Enumerable is a target for LINQ. The basic units of data in LINQ are sequences and elements.  A sequence is any object that implements IEnumerable<T> and an element is each item in the sequence
  • 4.
  • 5. There are a variety of flavors of LINQ for accessing and manipulating different data sources.  LINQ to Objects  LINQ to DataSets  LINQ to SQL  LINQ to Entities  LINQ to XML
  • 6. Application LINQ to SQL SQL Server from c in db.Customers where c.City == "London" select c.CompanyName Enumerate SELECT CompanyName FROM Customer WHERE City = 'London' SQL Query or SProc Rows Objects db.Customers.Add(c1); c2.City = “Seattle"; db.Customers.Remove(c3); SubmitChanges() INSERT INTO Customer … UPDATE Customer … DELETE FROM Customer … DML or SProcs
  • 7.  In the Enumerable class in System.Linq, there are around 40 query operators—all implemented as static extension methods. These are called standard query operators.  Queries that operate over local sequences are called local queries or LINQ-to-objects queries.  LINQ also supports sequences that can be dynamically fed from a remote data source such as a SQL Server. These sequences additionally implement the IQueryable<T>interface and are supported through a matching set of standard query operators in the Queryable class.  A query is an expression that, when enumerated, transforms sequences with query operators.
  • 8.  The standard query operators provide query capabilities including › Filtering – where › Projection – select, selectMany › Aggregation – Sum, Max, Count, Average › Sorting – orderby › Grouping – groupby › … and many more  A query operator is a method that transforms a sequence.  A typical query operator accepts an input sequence and emits a transformed output sequence.  Two sets of LINQ standard operators › Operating on IEnumerable<T> › Operating on IQueryable<T>
  • 9.  LINQ makes heavy use of Generics. Additionally, there were a number of features added to the Visual Basic and C# languages specifically to support LINQ.  Type inference  Extension Methods  Object initializer  Anonymous types  Lambda expressions  Query expressions
  • 10.  All LINQ query operations consist of three distinct actions: › Obtain the data source › Create the query › Execute the query
  • 11.  Fluent syntax is the most flexible and fundamental.  To build more complex queries, you append additional query operators to the expression, creating a chain.  When query operators are chained as in this example, the output sequence of one operator is the input sequence of the next.
  • 12.  Delcare Variable with “var” keyword  Compiler infers correct type › Based on initialization  Only for local, (non-null) initialized variables Customer c = new Customer(“Bob”, “Smith”, 1234); var c = new Customer(“Bob”, “Smith”, 1234); var c; // No var c = null; // No var c = default(string); // Yes public var DoThis(int x){} // No public void DoThis(var x){} // No
  • 13. Extension methods enable you to add methods to a data type or interface from outside the definition. This feature enables you to, in effect, add new methods to an existing type without actually modifying the type.  Extends Existing Types  Adds Methods Without Derivation  Accesses Public Members of Extended Types  Must be: › public and static › Housed within a static class
  • 14.  Anonymous Methods  The query operator evaluates your lambda expression upon demand—typically once per element in the input sequence.  Lambda expressions allow you to feed your own logic into the query operators.  Example:
  • 15.  C# provides a syntactic shortcut for writing LINQ queries, called query expressions.  At compile time, query syntax is converted into method calls to a LINQ provider's
  • 16.  Query expressions always start with a from clause and end with either a select or group clause.  The from clause declares a range variable (in this case, n), which you can think of as traversing the input sequence—rather like foreach
  • 17. An important feature of most query operators is that they execute not when constructed, but when enumerated (in other words, when MoveNext is called on its enumerator). Consider the following query:
  • 18.  Chaining Decorators  Chaining query operators creates a layering of decorators. Consider the following query:
  • 19.  All standard query operators provide deferred execution, with the following exceptions: › Operators that return a single element or scalar value, such as First or Count › The following conversion operators:  ToArray, ToList, ToDictionary, ToLookup  These operators cause immediate query execution because their result types have no mechanism for providing deferred execution. The Count method, for instance, returns a simple integer, which doesn’t then get enumerated. The following query is executed immediately:
  • 20.  If your query’s lambda expressions capture outer variables, the query will honor the value of the those variables at the time the query runs:
  • 21.  Familiar syntax for writing queries.  Compile-time checking for syntax errors and type safety.  Improved debugger support.  Powerful filtering, ordering, and grouping capabilities.  Consistent model for working with data across various kinds of data sources and formats.
  • 22.
  • 23.  Subquery is a query contained within another query’s lambda expression.