0% found this document useful (0 votes)
68 views16 pages

LINQ Language Integrated Query. LINQ Is Coming With C# 3.0

LINQ (Language Integrated Query) allows querying of different data sources like relational data, XML documents, and .NET objects using a common syntax. It provides compile-time checking and IntelliSense support. LINQ queries can be used to read, create and update databases using technologies like DLINQ and XML files using XLINQ. LINQ takes advantage of new C# 3.0 features like implicitly typed variables, extension methods, lambda expressions and anonymous types.

Uploaded by

manojkr045
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views16 pages

LINQ Language Integrated Query. LINQ Is Coming With C# 3.0

LINQ (Language Integrated Query) allows querying of different data sources like relational data, XML documents, and .NET objects using a common syntax. It provides compile-time checking and IntelliSense support. LINQ queries can be used to read, create and update databases using technologies like DLINQ and XML files using XLINQ. LINQ takes advantage of new C# 3.0 features like implicitly typed variables, extension methods, lambda expressions and anonymous types.

Uploaded by

manojkr045
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

LINQ

LINQ = Language Integrated Query. LINQ is coming with C# 3.0. LINQ will extend the .NET framework by providing general purpose query facilities that apply to all sources of information.

Advantages of LINQ

For now : one source = one query language.


Relational data XML documents .NET objects SQL XPath .NET built-in operators (foreach...)

With LINQ : many sources = one query language.


Relational data XML documents .NET objects

LINQ

Advantages of LINQ

For now : dynamically-created string queries. - Doesn't provide compile-time checking. - Native code and non-native code is mixed.

Advantages of LINQ

With LINQ : static typing. - Compile-time syntax checking, - IntelliSense, - Native code.

A sample User class

A sample User list

LINQ syntax

General syntax of a simple query expression :

LINQ syntax

How going through the results of the query ?

More complex queries

Order by, Group by assertions :

More complex queries

Result of the previous query :

Using LINQ instead of SQL

DLINQ : a LINQ technology allowing to use LINQ queries to create, read, and update a database. How does it work ?

First, define classes following the database schema (a class = a table, a property = a column), Then, create a DataContext object, linked to the database, and get one object per table (object of the classes defined above). Finally, make LINQ queries on these objects.

Using LINQ instead of SQL

Using LINQ to read XML files

XLINQ : a LINQ technology allowing to use LINQ queries to create, read, and update an XML file.

Using LINQ to read XML files

Using LINQ to read XML files

LINQ

LINQ takes advantage of the new features of C# 3.0 :


Implicitly-typed variables (var keyword), Extension methods, Lambda expressions, Anonymous types, ...

The LINQ project page : Introduction to LINQ :

http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx

ftp://ftp-developpez.com/morpheus/linq/linq.pdf

You might also like