2. What is LINQ
• Language Integrated Query (LINQ, pronounced "link") is
a Microsoft .NET Framework component that adds native
data querying capabilities to .NET languages, although ports exist
for Java, PHP, JavaScript, TypeScript, and ActionScript.
• LINQ was released as a major part of .NET Framework 3.5 on November
19, 2007.
3. Why LINQ
• LINQ is a query syntax, not a language or an O/RM.
You can build an O/RM on top of the syntax
provided by LINQ
• Familiar language to code in (C#/ VB.NET)
• Easier to maintain (we have more .NET than SQL
gurus on staff)
• SQL generated is well structured and very optimal
• Allows direct translation of business rules to SQL
while still keeping all business logic in a single
project
5. Types of LINQ
• LINQ to Objects: Provides queries on any kind of C# in-memory object, such as
arrays, lists, and other collection types.
• LINQ to XML: Provides creation and manipulation of XML documents using the
same syntax and general query mechanism as the other LINQ varieties.
• LINQ to ADO.NET: ADO.NET or Active Data Objects for .NET is an umbrella term
that includes all the different classes and libraries in .NET for accessing data in
databases, such as Microsoft SQL Server, Oracle, and others. LINQ to ADO.NET
includes LINQ to Entities, LINQ to DataSet, and LINQ to SQL.
• LINQ to Entities: The ADO.NET Entity Framework is the newest set of data
interface classes in .NET 4, recommended by Microsoft for new development.
• LINQ to DataSet: The DataSet object was introduced in the first version of the
.NET Framework. This variety of LINQ enables legacy .NET data to be queried
easily with LINQ.
• LINQ to SQL: This is an alternate LINQ interface for .NET 3.5, targeted mainly at
Microsoft SQL Server, that has been superseded by LINQ to Entities in .NET 4.
• PLINQ: PLINQ or Parallel LINQ extends LINQ to Objects with a parallel
programming library that can split up a query to execute simultaneously on a
multicore processor.
9. Benefits of LINQ
• These features make it easy to write accurate
queries and to discover mistakes at design time.
• Time consuming
• Tables are automatically created into class
• Columns are automatically created into properties
• Relationship are automatically appeaded to classes
• queries with the integrated debugger.
• Lambda expressions are awesome
• Data is easy to setup and use
10. Disadvantages of LINQ
• No clear outline for Tiers
• No good way of view permissions
• Small data sets will take longer to build the query
than execute
• There is an overhead for creating queries
• When queries are moved from sql to application
side, joins are very slow
• DBML concurrency issues
• Hard to understand advance queries using
Expressions
11. Advanced LINQ to SQL features
• Handling concurrency
• Working directly with the database using pass-
through queries, stored procedures, and user
defined functions
• Improving the business tier with compiled queries,
partial classes, partial methods, and object
inheritance
• Comparison of LINQ to SQL with LINQ to Entities
13. Linq Query or Lambda expression
• Lambda expression:Query Expression compiles into
Method Expression
14. Entity Framework vs LINQ to SQL
• Entity Framework
Enterprise Development.
Works with Conceptual model of database.
Works with all data sources.
".EDMX" is created while using Entity Framework.
• LINQ
Rapid Application Development.
Works with objects in database.
Mainly woks with SQL Server.
".dbml" is created while using LINQ to SQL.