D4 Introduction to LINQ

Preview:

DESCRIPTION

Introduction to LINQ with C# programming

Citation preview

Introduction to LINQ

Pakorn Weecharungsan

Contents

What is LINQ? LINQ Providers Fundamental LINQ syntax

What is LINQ?

LINQ (Language Integrated Query) is a new feature of C# and Visual Basic .NET that integrates into these languages the ability to query data

What is LINQ?

LINQ Providers

LINQ to Objects LINQ to XML LINQ Support for ADO.NET

LINQ to SQLLINQ to DatasetsLINE to Entities

Query Syntax and Method Syntax

Query syntax is a declarative form that looks very much like an SQL statement. Query syntax is written in the form of query expressions

Method syntax is an imperative form, which uses standard method invocations. The methods are from a set called the standard query operators

Query Syntax and Method Syntax

The Structure of Query Expressions

The from clause

The from clause specifies the data collection that is to be used as the data source. It also introduces the iteration variable

The join clause

The join clause in LINQ is much like the JOIN clause in SQL

The where Clause

The where clause eliminates items from further consideration if they don’t meet the specified condition. The syntax of the where clause is the following

The where Clause

The orderby Clause

The orderby clause takes an expression and returns the result items in order according to the expression

The orderby Clause

The group Clause

The group clause groups the selected objects according to some criterion. For example, with the array of students in the previous examples, the program could group the students according to their majors

The group Clause

The Standard Query Operators

The standard query operators comprise a set of methods called an application programming interface (API) that lets you query any .NET array or collection

The Standard Query Operators

Recommended