<s>
Language	B-Language
Integrated	I-Language
Query	I-Language
(	O
LINQ	B-Language
,	O
pronounced	O
"	O
link	O
"	O
)	O
is	O
a	O
Microsoft	B-Application
.NET	I-Application
Framework	I-Application
component	O
that	O
adds	O
native	O
data	O
querying	B-Language
capabilities	O
to	O
.NET	B-Language
languages	I-Language
,	O
originally	O
released	O
as	O
a	O
major	O
part	O
of	O
.NET	B-Application
Framework	I-Application
3.5	O
in	O
2007	O
.	O
</s>
<s>
LINQ	B-Language
extends	O
the	O
language	O
by	O
the	O
addition	O
of	O
query	B-Language
expressions	O
,	O
which	O
are	O
akin	O
to	O
SQL	B-Language
statements	O
,	O
and	O
can	O
be	O
used	O
to	O
conveniently	O
extract	O
and	O
process	O
data	O
from	O
arrays	B-Data_Structure
,	O
enumerable	O
classes	O
,	O
XML	B-Protocol
documents	I-Protocol
,	O
relational	B-Application
databases	I-Application
,	O
and	O
third-party	O
data	O
sources	O
.	O
</s>
<s>
Other	O
uses	O
,	O
which	O
utilize	O
query	B-Language
expressions	O
as	O
a	O
general	O
framework	O
for	O
readably	O
composing	O
arbitrary	O
computations	O
,	O
include	O
the	O
construction	O
of	O
event	O
handlers	O
or	O
monadic	O
parsers	B-Language
.	O
</s>
<s>
It	O
also	O
defines	O
a	O
set	O
of	O
method	O
names	O
(	O
called	O
standard	O
query	B-Language
operators	O
,	O
or	O
standard	O
sequence	O
operators	O
)	O
,	O
along	O
with	O
translation	O
rules	O
used	O
by	O
the	O
compiler	O
to	O
translate	O
query	B-Language
syntax	O
expressions	O
into	O
expressions	O
using	O
fluent-style	O
(	O
called	O
method	O
syntax	O
by	O
Microsoft	O
)	O
with	O
these	O
method	O
names	O
,	O
lambda	B-General_Concept
expressions	I-General_Concept
and	O
anonymous	B-Language
types	I-Language
.	O
</s>
<s>
Ports	O
of	O
LINQ	B-Language
exist	O
for	O
PHP	B-Application
(	O
)	O
,	O
JavaScript	B-Language
(	O
)	O
,	O
TypeScript	B-Language
(	O
)	O
,	O
and	O
ActionScript	B-Operating_System
(	O
)	O
,	O
although	O
none	O
are	O
strictly	O
equivalent	O
to	O
LINQ	B-Language
in	O
the	O
.NET	B-Application
inspired	O
languages	O
C#	B-Application
,	O
F#	B-Operating_System
and	O
VB.NET	B-Language
(	O
where	O
it	O
is	O
a	O
part	O
of	O
the	O
language	O
,	O
not	O
an	O
external	O
library	B-Library
,	O
and	O
where	O
it	O
often	O
addresses	O
a	O
wider	O
range	O
of	O
needs	O
)	O
.	O
</s>
<s>
These	O
functions	O
may	O
be	O
supplied	O
in	O
the	O
form	O
of	O
a	O
named	O
method	O
or	O
anonymous	B-General_Concept
function	I-General_Concept
.	O
</s>
<s>
The	O
set	O
of	O
query	B-Language
operators	O
defined	O
by	O
LINQ	B-Language
is	O
exposed	O
to	O
the	O
user	O
as	O
the	O
Standard	O
Query	B-Language
Operator	O
(	O
SQO	O
)	O
API	B-General_Concept
.	O
</s>
<s>
The	O
query	B-Language
operators	O
supported	O
by	O
the	O
API	B-General_Concept
are	O
:	O
</s>
<s>
The	O
user	O
supplies	O
an	O
arbitrary	O
function	O
,	O
in	O
the	O
form	O
of	O
a	O
named	O
or	O
lambda	B-General_Concept
expression	I-General_Concept
,	O
which	O
projects	O
the	O
data	O
members	O
.	O
</s>
<s>
First	O
,	O
every	O
element	O
is	O
mapped	B-General_Concept
to	O
its	O
corresponding	O
collection	O
.	O
</s>
<s>
The	O
translation	O
rules	O
mentioned	O
above	O
still	O
make	O
it	O
mandatory	O
for	O
a	O
LINQ	B-Language
provider	O
to	O
provide	O
the	O
other	O
two	O
operators	O
.	O
</s>
<s>
Overloaded	O
versions	O
take	O
no	O
function	O
and	O
act	O
as	O
if	O
the	O
identity	O
is	O
given	O
as	O
the	O
lambda	B-General_Concept
.	O
</s>
<s>
The	O
GroupJoin	O
operator	O
performs	O
a	O
group	B-Language
join	I-Language
.	O
</s>
<s>
The	O
Standard	O
Query	B-Language
Operator	O
API	B-General_Concept
also	O
specifies	O
certain	O
operators	O
that	O
convert	O
a	O
collection	O
into	O
another	O
type	O
:	O
</s>
<s>
AsQueryable	O
:	O
Statically	O
types	O
the	O
collection	O
as	O
an	O
IQueryablexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
.	O
</s>
<s>
ToDictionary	O
:	O
Creates	O
a	O
Dictionaryxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
from	O
the	O
collection	O
,	O
indexed	O
by	O
the	O
key	O
K	O
.	O
A	O
user	O
supplied	O
projection	B-Algorithm
function	O
extracts	O
a	O
key	O
from	O
each	O
element	O
.	O
</s>
<s>
ToLookup	O
:	O
Creates	O
a	O
Lookupxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
from	O
the	O
collection	O
,	O
indexed	O
by	O
the	O
key	O
K	O
.	O
A	O
user	O
supplied	O
projection	B-Algorithm
function	O
extracts	O
a	O
key	O
from	O
each	O
element	O
.	O
</s>
<s>
While	O
LINQ	B-Language
is	O
primarily	O
implemented	O
as	O
a	O
library	B-Library
for	O
.NET	B-Application
Framework	I-Application
3.5	O
,	O
it	O
also	O
defines	O
optional	O
language	O
extensions	O
that	O
make	O
queries	B-Language
a	O
first-class	O
language	B-Language
construct	I-Language
and	O
provide	O
syntactic	O
sugar	O
for	O
writing	O
queries	B-Language
.	O
</s>
<s>
These	O
language	O
extensions	O
have	O
initially	O
been	O
implemented	O
in	O
C#	B-Application
3.0	O
,	O
VB	B-Language
9.0	I-Language
,	O
F#	B-Operating_System
and	O
Oxygene	B-Language
,	O
with	O
other	O
languages	O
like	O
Nemerle	B-Application
having	O
announced	O
preliminary	O
support	O
.	O
</s>
<s>
Query	B-Language
syntax	O
:	O
A	O
language	O
is	O
free	O
to	O
choose	O
a	O
query	B-Language
syntax	O
that	O
it	O
will	O
recognize	O
natively	O
.	O
</s>
<s>
These	O
language	O
keywords	O
must	O
be	O
translated	O
by	O
the	O
compiler	O
to	O
appropriate	O
LINQ	B-Language
method	O
calls	O
.	O
</s>
<s>
The	O
languages	O
C#	B-Application
3.0	O
and	O
Oxygene	B-Language
declare	O
them	O
with	O
the	O
var	O
keyword	O
.	O
</s>
<s>
Such	O
objects	O
are	O
still	O
strongly	O
typed	O
;	O
for	O
these	O
objects	O
the	O
compiler	O
infers	O
the	O
types	O
of	O
variables	O
via	O
type	O
inference	O
,	O
which	O
allows	O
the	O
results	O
of	O
the	O
queries	B-Language
to	O
be	O
specified	O
and	O
defined	O
without	O
declaring	O
the	O
type	O
of	O
the	O
intermediate	O
variables	O
.	O
</s>
<s>
Anonymous	B-Language
types	I-Language
:	O
Anonymous	B-Language
types	I-Language
allow	O
classes	O
that	O
contain	O
only	O
data-member	O
declarations	O
to	O
be	O
inferred	O
by	O
the	O
compiler	O
.	O
</s>
<s>
Lambda	B-General_Concept
expressions	I-General_Concept
:	O
Lambda	B-General_Concept
expressions	I-General_Concept
allow	O
predicates	O
and	O
other	O
projection	B-Algorithm
functions	O
to	O
be	O
written	O
inline	O
with	O
a	O
concise	O
syntax	O
,	O
and	O
support	O
full	O
lexical	O
closure	O
.	O
</s>
<s>
They	O
are	O
captured	O
into	O
parameters	O
as	O
delegates	O
or	O
expression	O
trees	O
depending	O
on	O
the	O
Query	B-Language
Provider	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
the	O
query	B-Language
to	O
select	O
all	O
the	O
objects	O
in	O
a	O
collection	O
with	O
SomeProperty	O
less	O
than	O
10	O
,	O
</s>
<s>
The	O
C	O
#3	O
.0	O
specification	O
defines	O
a	O
Query	B-Language
Expression	O
Pattern	O
along	O
with	O
translation	O
rules	O
from	O
a	O
LINQ	B-Language
expression	O
to	O
an	O
expression	O
in	O
a	O
subset	O
of	O
C#	B-Application
3.0	O
without	O
LINQ	B-Language
expressions	O
.	O
</s>
<s>
The	O
translation	O
thus	O
defined	O
is	O
actually	O
un-typed	O
,	O
which	O
,	O
in	O
addition	O
to	O
lambda	B-General_Concept
expressions	I-General_Concept
being	O
interpretable	O
as	O
either	O
delegates	O
or	O
expression	O
trees	O
,	O
allows	O
for	O
a	O
great	O
degree	O
of	O
flexibility	O
for	O
libraries	O
wishing	O
to	O
expose	O
parts	O
of	O
their	O
interface	O
as	O
LINQ	B-Language
expression	O
clauses	O
.	O
</s>
<s>
IEnumerable	O
<	O
T>s	O
and	O
with	O
delegates	O
,	O
whereas	O
LINQ	B-Language
to	O
SQL	B-Language
makes	O
use	O
of	O
the	O
expression	O
trees	O
.	O
</s>
<s>
The	O
expression	O
trees	O
are	O
at	O
the	O
core	O
of	O
the	O
LINQ	B-Language
extensibility	O
mechanism	O
,	O
by	O
which	O
LINQ	B-Language
can	O
be	O
adapted	O
for	O
many	O
data	O
sources	O
.	O
</s>
<s>
The	O
expression	O
trees	O
are	O
handed	O
over	O
to	O
LINQ	B-Language
Providers	O
,	O
which	O
are	O
data	O
source-specific	O
implementations	O
that	O
adapt	O
the	O
LINQ	B-Language
queries	B-Language
to	O
be	O
used	O
with	O
the	O
data	O
source	O
.	O
</s>
<s>
If	O
they	O
choose	O
so	O
,	O
the	O
LINQ	B-Language
Providers	O
analyze	O
the	O
expression	O
trees	O
contained	O
in	O
a	O
query	B-Language
in	O
order	O
to	O
generate	O
essential	O
pieces	O
needed	O
for	O
the	O
execution	O
of	O
a	O
query	B-Language
.	O
</s>
<s>
This	O
can	O
be	O
SQL	B-Language
fragments	O
or	O
any	O
other	O
completely	O
different	O
representation	O
of	O
code	O
as	O
further	O
manipulatable	O
data	O
.	O
</s>
<s>
LINQ	B-Language
comes	O
with	O
LINQ	B-Language
Providers	O
for	O
in-memory	O
object	O
collections	O
,	O
Microsoft	B-Application
SQL	I-Application
Server	I-Application
databases	B-Application
,	O
ADO.NET	B-Device
datasets	O
and	O
XML	B-Protocol
documents	I-Protocol
.	O
</s>
<s>
These	O
different	O
providers	O
define	O
the	O
different	O
flavors	O
of	O
LINQ	B-Language
:	O
</s>
<s>
The	O
LINQ	B-Language
to	O
Objects	O
provider	O
is	O
used	O
for	O
in-memory	O
collections	O
,	O
using	O
the	O
local	O
query	B-Language
execution	O
engine	O
of	O
LINQ	B-Language
.	O
</s>
<s>
The	O
code	O
generated	O
by	O
this	O
provider	O
refers	O
to	O
the	O
implementation	O
of	O
the	O
standard	O
query	B-Language
operators	O
as	O
defined	O
on	O
the	O
Sequence	O
pattern	O
and	O
allows	O
IEnumerablexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
collections	O
to	O
be	O
queried	O
locally	O
.	O
</s>
<s>
Current	O
implementation	O
of	O
LINQ	B-Language
to	O
Objects	O
perform	O
interface	O
implementation	O
checks	O
to	O
allow	O
for	O
fast	O
membership	O
tests	O
,	O
counts	O
,	O
and	O
indexed	O
lookup	O
operations	O
when	O
they	O
are	O
supported	O
by	O
the	O
runtime	O
type	O
of	O
the	O
IEnumerable	O
.	O
</s>
<s>
The	O
LINQ	B-Language
to	O
XML	B-Protocol
provider	O
converts	O
an	O
XML	B-Protocol
document	I-Protocol
to	O
a	O
collection	O
of	O
XElement	O
objects	O
,	O
which	O
are	O
then	O
queried	O
against	O
using	O
the	O
local	O
execution	O
engine	O
that	O
is	O
provided	O
as	O
a	O
part	O
of	O
the	O
implementation	O
of	O
the	O
standard	O
query	B-Language
operator	O
.	O
</s>
<s>
The	O
LINQ	B-Language
to	O
SQL	B-Language
provider	O
allows	O
LINQ	B-Language
to	O
be	O
used	O
to	O
query	B-Language
Microsoft	B-Application
SQL	I-Application
Server	I-Application
databases	B-Application
,	O
including	O
SQL	B-Operating_System
Server	I-Operating_System
Compact	I-Operating_System
databases	B-Application
.	O
</s>
<s>
Since	O
SQL	B-Language
Server	O
data	O
may	O
reside	O
on	O
a	O
remote	O
server	O
,	O
and	O
because	O
SQL	B-Language
Server	O
has	O
its	O
own	O
query	B-Language
engine	O
,	O
LINQ	B-Language
to	O
SQL	B-Language
does	O
not	O
use	O
the	O
query	B-Language
engine	O
of	O
LINQ	B-Language
.	O
</s>
<s>
Instead	O
,	O
it	O
converts	O
a	O
LINQ	B-Language
query	B-Language
to	O
a	O
SQL	B-Language
query	B-Language
that	O
is	O
then	O
sent	O
to	O
SQL	B-Language
Server	O
for	O
processing	O
.	O
</s>
<s>
However	O
,	O
since	O
SQL	B-Language
Server	O
stores	O
the	O
data	O
as	O
relational	B-Application
data	I-Application
and	O
LINQ	B-Language
works	O
with	O
data	O
encapsulated	O
in	O
objects	O
,	O
the	O
two	O
representations	O
must	O
be	O
mapped	B-General_Concept
to	O
one	O
another	O
.	O
</s>
<s>
For	O
this	O
reason	O
,	O
LINQ	B-Language
to	O
SQL	B-Language
also	O
defines	O
a	O
mapping	O
framework	O
.	O
</s>
<s>
The	O
correspondence	O
,	O
along	O
with	O
other	O
relational	B-Architecture
model	I-Architecture
attributes	B-General_Concept
such	O
as	O
primary	B-Application
keys	I-Application
,	O
are	O
specified	O
using	O
LINQ	B-Language
to	O
SQL-defined	O
attributes	B-General_Concept
.	O
</s>
<s>
The	O
classes	O
must	O
be	O
defined	O
before	O
LINQ	B-Language
to	O
SQL	B-Language
can	O
be	O
used	O
.	O
</s>
<s>
Visual	B-Application
Studio	I-Application
2008	I-Application
includes	O
a	O
mapping	O
designer	O
that	O
can	O
be	O
used	O
to	O
create	O
the	O
mapping	O
between	O
the	O
data	O
schemas	B-Application
in	O
the	O
object	O
as	O
well	O
as	O
the	O
relational	O
domain	O
.	O
</s>
<s>
It	O
can	O
automatically	O
create	O
the	O
corresponding	O
classes	O
from	O
a	O
database	B-Application
schema	I-Application
,	O
as	O
well	O
as	O
allow	O
manual	O
editing	O
to	O
create	O
a	O
different	O
view	O
by	O
using	O
only	O
a	O
subset	O
of	O
the	O
tables	O
or	O
columns	O
in	O
a	O
table	O
.	O
</s>
<s>
The	O
mapping	O
is	O
implemented	O
by	O
the	O
DataContext	O
that	O
takes	O
a	O
connection	O
string	O
to	O
the	O
server	O
,	O
and	O
can	O
be	O
used	O
to	O
generate	O
a	O
Tablexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
where	O
T	O
is	O
the	O
type	O
to	O
which	O
the	O
database	O
table	O
will	O
be	O
mapped	B-General_Concept
.	O
</s>
<s>
The	O
Tablexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
interface	O
,	O
so	O
that	O
the	O
expression	O
tree	O
is	O
created	O
,	O
which	O
the	O
LINQ	B-Language
to	O
SQL	B-Language
provider	O
handles	O
.	O
</s>
<s>
It	O
converts	O
the	O
query	B-Language
into	O
T-SQL	B-Language
and	O
retrieves	O
the	O
result	O
set	O
from	O
the	O
database	O
server	O
.	O
</s>
<s>
Since	O
the	O
processing	O
happens	O
at	O
the	O
database	O
server	O
,	O
local	O
methods	O
,	O
which	O
are	O
not	O
defined	O
as	O
a	O
part	O
of	O
the	O
lambda	B-General_Concept
expressions	I-General_Concept
representing	O
the	O
predicates	O
,	O
cannot	O
be	O
used	O
.	O
</s>
<s>
However	O
,	O
it	O
can	O
use	O
the	O
stored	B-General_Concept
procedures	I-General_Concept
on	O
the	O
server	O
.	O
</s>
<s>
Since	O
the	O
LINQ	B-Language
to	O
SQL	B-Language
provider	O
(	O
above	O
)	O
works	O
only	O
with	O
Microsoft	B-Application
SQL	I-Application
Server	I-Application
databases	B-Application
,	O
in	O
order	O
to	O
support	O
any	O
generic	O
database	O
,	O
LINQ	B-Language
also	O
includes	O
the	O
LINQ	B-Language
to	O
DataSets	O
.	O
</s>
<s>
It	O
uses	O
ADO.NET	B-Device
to	O
handle	O
the	O
communication	O
with	O
the	O
database	O
.	O
</s>
<s>
Once	O
the	O
data	O
is	O
in	O
ADO.NET	B-Device
Datasets	O
,	O
LINQ	B-Language
to	O
DataSets	O
execute	O
queries	B-Language
against	O
these	O
datasets	O
.	O
</s>
<s>
Non-professional	O
users	O
may	O
struggle	O
with	O
subtleties	O
in	O
the	O
LINQ	B-Language
to	O
Objects	O
features	O
and	O
syntax	O
.	O
</s>
<s>
Naive	O
LINQ	B-Language
implementation	O
patterns	O
can	O
lead	O
to	O
a	O
catastrophic	O
degradation	O
of	O
performance	O
.	O
</s>
<s>
LINQ	B-Language
to	O
XML	B-Protocol
and	O
LINQ	B-Language
to	O
SQL	B-Language
performance	O
compared	O
to	O
ADO.NET	B-Device
depends	O
on	O
the	O
use	O
case	O
.	O
</s>
<s>
Version	O
4	O
of	O
the	O
.NET	B-Application
framework	I-Application
includes	O
PLINQ	B-Library
,	O
or	O
Parallel	B-Operating_System
LINQ	B-Language
,	O
a	O
parallel	B-Operating_System
execution	O
engine	O
for	O
LINQ	B-Language
queries	B-Language
.	O
</s>
<s>
Any	O
implementation	O
of	O
the	O
IEnumerablexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1	O
)	O
extension	O
method	O
defined	O
by	O
the	O
ParallelEnumerable	O
class	O
in	O
the	O
System.Linq	O
namespace	O
of	O
the	O
.NET	B-Application
framework	I-Application
.	O
</s>
<s>
The	O
PLINQ	B-Library
engine	O
can	O
execute	O
parts	O
of	O
a	O
query	B-Language
concurrently	O
on	O
multiple	O
threads	O
,	O
providing	O
faster	O
results	O
.	O
</s>
<s>
Many	O
of	O
the	O
concepts	O
that	O
LINQ	B-Language
introduced	O
were	O
originally	O
tested	O
in	O
Microsoft	O
's	O
Cω	O
research	O
project	O
,	O
formerly	O
known	O
by	O
the	O
codenames	O
X#	O
(	O
X	O
Sharp	O
)	O
and	O
Xen	O
.	O
</s>
<s>
It	O
was	O
renamed	O
Cω	O
after	O
Polyphonic	O
C#	B-Application
,	O
another	O
research	O
language	O
based	O
on	O
the	O
join	O
calculus	O
,	O
was	O
integrated	O
into	O
it	O
.	O
</s>
<s>
Cω	O
attempts	O
to	O
make	O
datastores	O
(	O
such	O
as	O
databases	B-Application
and	O
XML	B-Protocol
documents	I-Protocol
)	O
accessible	O
with	O
the	O
same	O
ease	O
and	O
type	B-Language
safety	I-Language
as	O
traditional	O
types	O
like	O
strings	O
and	O
arrays	B-Data_Structure
.	O
</s>
<s>
Many	O
of	O
these	O
ideas	O
were	O
inherited	O
from	O
an	O
earlier	O
incubation	O
project	O
within	O
the	O
WebData	O
XML	B-Protocol
team	O
called	O
X#	O
and	O
Xen	O
.	O
</s>
<s>
Cω	O
also	O
includes	O
new	O
constructs	O
to	O
support	O
concurrent	B-Architecture
programming	I-Architecture
;	O
these	O
features	O
were	O
largely	O
derived	O
from	O
the	O
earlier	O
Polyphonic	O
C#	B-Application
project	O
.	O
</s>
<s>
First	O
available	O
in	O
2004	O
as	O
a	O
compiler	O
preview	O
,	O
Cω	O
's	O
features	O
were	O
subsequently	O
used	O
by	O
Microsoft	O
in	O
the	O
creation	O
of	O
the	O
LINQ	B-Language
features	O
released	O
in	O
2007	O
in	O
.NET	B-Application
version	O
3.5	O
The	O
concurrency	B-Architecture
constructs	O
have	O
also	O
been	O
released	O
in	O
a	O
slightly	O
modified	O
form	O
as	O
a	O
library	B-Library
,	O
named	O
Joins	B-Library
Concurrency	B-Architecture
Library	B-Library
,	O
for	O
C#	B-Application
and	O
other	O
.NET	B-Language
languages	I-Language
by	O
Microsoft	O
Research	O
.	O
</s>
