Basics of LINQ

Some notes on LINQ
Language-Integrated Query (LINQ) is the technology that provides tools for developers to use query directly in the programming language (C#). A query is an expression that retrieves data from a data source. In LINQ, you work with objects. You use the codes to query and transform data in XML documents, SQL databases, Datasets, collections, and any other format that LINQ is available.

All LINQ operations include there actions:

  1. Obtain the data source.
  2. Create the query.
  3. Execute the query.

A simple example of LINQ:


//DATA RESOURCE
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

// QUERY
var queryLowNums =
from num in numbers
where num < 6
select num;

//EXECUTION
foreach (int num in numQuery)
{
Console.Write("{0,1} ", num);
}

This is just an introduction to LINQ. I will share more while I build with it.

Advertisements

#linq-2