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
This entry was posted in C#, LINQ and tagged . Bookmark the permalink.

2 Responses to Basics of LINQ

  1. Pingback: Basics of LINQ II | mehmetcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s