SlideShare ist ein Scribd-Unternehmen logo
1 von 24
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

Weitere ähnliche Inhalte

Was ist angesagt?

Java 8 - Project Lambda
Java 8 - Project LambdaJava 8 - Project Lambda
Java 8 - Project LambdaRahman USTA
 
Apollo Server III
Apollo Server IIIApollo Server III
Apollo Server IIINodeXperts
 
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 AngularMA Jiangfan
 
Introduction to RxJava on Android
Introduction to RxJava on AndroidIntroduction to RxJava on Android
Introduction to RxJava on AndroidChris Arriola
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakMarcus Denker
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C ProgrammingAnil Pokhrel
 
Functions and tasks in verilog
Functions and tasks in verilogFunctions and tasks in verilog
Functions and tasks in verilogNallapati 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 PromisesMarcus Denker
 
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 SmalltakMarcus Denker
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++Learn By Watch
 
Functional programming in Javascript
Functional programming in JavascriptFunctional programming in Javascript
Functional programming in JavascriptKnoldus Inc.
 
LINQ in Visual Studio 2008
LINQ in Visual Studio 2008LINQ in Visual Studio 2008
LINQ in Visual Studio 2008ukdpe
 

Was ist angesagt? (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
 

Andere mochten auch

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íaAndrea Zarai Estrada Buendia
 
Jason Zattler Wiser Insurance Agency
Jason Zattler Wiser Insurance AgencyJason Zattler Wiser Insurance Agency
Jason Zattler Wiser Insurance AgencyBNI
 
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 preocuparSymantec Brasil
 
Metas brasileiras pós-2020
Metas brasileiras pós-2020Metas brasileiras pós-2020
Metas brasileiras pós-2020Obsclima
 
Medical Termination of Pregnancy Act
Medical Termination of Pregnancy ActMedical Termination of Pregnancy Act
Medical Termination of Pregnancy Actprajs9
 
Webgearing - Apple's AppStore
Webgearing -  Apple's AppStoreWebgearing -  Apple's AppStore
Webgearing - Apple's AppStoreAberla
 
Job Satisfaction & Job Performance
Job Satisfaction & Job PerformanceJob Satisfaction & Job Performance
Job Satisfaction & Job Performancehanaalaydrus
 

Andere mochten auch (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
 

Ähnlich wie Link quries

Understanding LINQ in C#
Understanding LINQ in C# Understanding LINQ in C#
Understanding LINQ in C# MD. Shohag Mia
 
NHDay Introduction to LINQ2NH
NHDay Introduction to LINQ2NHNHDay Introduction to LINQ2NH
NHDay Introduction to LINQ2NHGian 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_ivNico Ludwig
 
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#5Peter Gfader
 
LINQ-Introduction.ppt
LINQ-Introduction.pptLINQ-Introduction.ppt
LINQ-Introduction.pptssusera8c91a
 
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 Overviewpradeepkothiyal
 
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
 
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
 
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 SP1ukdpe
 

Ähnlich wie 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
 

Kürzlich hochgeladen

UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 

Kürzlich hochgeladen (20)

UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 

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.