module 3: introduction to linq (powerpoint slides)
DESCRIPTION
Module 3: Introduction to LINQ (PowerPoint Slides)Jordan .NET User Group (Jordev)Community MaterialMohamed SalehTRANSCRIPT
Visual Studio 2008 Training
3.5 RTM3.5 RTM
Mohamed [email protected]
www.jordev.netwww.geeksconnected.com/mohamed
Module 3: Introduction To Linq
Overview
What is Linq
Understand the Query Expressions and Query Operators
Writing queries using extension methods
Using the Partitioning and Conversion operators
Explain the usage of the new Linq Assemblies
Enabling Linq to Objects for .Net Framework 2.0
Introducing LINQ Project
Linq is a set of language extensions that enable the query operations over the data.
Linq relies on the C# 3.0 Language Enhancements .
Linq Building Blocks:1. Object Initializers
2. Lambda Expressions
3. Extension Methods
4. Anonymous types
5. Implicit Typing Variables
LINQ Project Overview
LINQ Assemblies
The following describes the new assemblies and its use:• System.Core.dll: Extension Methods for IEnumerable<T> .
• System.Data.DataExtensions.dll: Providing LINQ for DataSet.
• System.Data.Linq.dll: LINQ implementation for SQL Server.
• System.Xml.Linq.dll: LINQ Implementation for XML
LINQ Assemblies
LINQ Query Expressions
What is Query?
What is Query Operators?
How to Write Query Expressions?
IEnumerable<T> and Query Results
What is Deferred Execution?
What is Immediate Execution?
LINQ Query Expressions
Lab 1: Writing Query Expressions
Writing Linq Query Expression.
Using Query Operators.
Using var and IEnumerable<T> query varaiables.
Querying In-Memory Collections.
Standard Query Operators
The System.Linq namespace contains different Linq Extensions under the System.Linq.Enumerable class.
Commonly Used Operators:1. OrderByDescending
2. OrderBy
3. Take
4. Sum
5. Distinct
6. Count
7. First
Standard Query Operators Overview
Lab 2: Using Initializers
Writing Queries using Linq Extension Methods.
Sorting the elements using the OrderByDescending extension method.
Returning specific elements using Take and First methods.
Calculating the total number of elements using the Count method.
Returning Distinct values from a sequence of values.
Conversion Operators
The conversion operator enable the conversion of query results into different collection types.
The query conversion operators:
1. ToArray
2. ToList
3. ToDictionary
4. OfType
Conversion Operators Overview
Lab 3: Using Conversion Operators
Enforce the immediate execution of the queries.
Converting the query results to Different Collection Types.
Filtering the query results based on a specific data type.
Partitioning Operators
Linq extension methods set contain a group of operators that allows the programmer to partitioning the results of the query into a specific sequence.
The query partitioning operators:1. Take
2. Skip
3. TakeWhile
4. SkipWhile
Partitioning Operators Overview
Lab 4: Using Partitioning Operators
Use the partitioning query operators.
Skipping elements based on conditional expression.
Retrieving elements using Take and TakeWhile operators.
LINQ Bridge
LINQ Implemented for .NET 3.5, which requires the client to install .NET Framework 3.5.
LINQBridge is an open project contains a reimplementation for all standard query operators
LINQBridge utilize the Csharp 3.0 Compiler new features to enable LINQ for .NET 2.0 Applications.
LINQBridge can be used in Visual Studio 2008 for writing LINQ to Objects expressions.
LINQBridge can be used in Visual Studio 2005 using the extension methods style.
LINQ Bridge Overview
Lab 5: Using LINQ for .NET Framework 2.0
Writing Linq-Enabled Applications for .NET Framework 2.0.
Using the LinqBridge Extension in Visual Studio 2008.
Writing Linq to Objects expressions.
Review
In this module, you learned to:In this module, you learned to:
Writing Query Expressions
Writing Queries using extension methods directly
Using different query operators
Enabling Linq to Objects into .NET Framework 2.0 Applications
Writing Query Expressions
Writing Queries using extension methods directly
Using different query operators
Enabling Linq to Objects into .NET Framework 2.0 Applications