<pedrocorreia.net ⁄>
 

<The LINQ Farm: LINQ for Beginners ⁄ >




clicks: 3405 3405 2006-11-07 2006-11-07 goto programacao myNews programacao  Bookmark This Bookmark This


This is the first in a series of posts on C# and LINQ. These posts will describe a natural, easy to understand technique for querying data. When using LINQ, simply declare the question you want to ask, and then sit back and wait while the computer analyzes your query and finds an optimal way to retrieve your answer.

The development of LINQ involved input from many of the best minds at Microsoft. Anders Hejlsberg, researchers at the Microsoft research centers in Redmond and in Cambridge, England, the C# developer and test teams, the C# program managers, and others all contributed to the development of this language. As a result, it represents one of the major technical achievments that has come out of the Microsoft Developer Division in recent years.

When you hear talk about querying data, it is easy to imagine the kind of data that resides in a database. And indeed, you can use LINQ to query data in a database. However, LINQ does more than just run SQL queries. It can be used with almost any kind of data.

The acronym LINQ stands for Language Integrated Query. This means that LINQ is a technique for querying data that has been integrated into the C# language. For database programmers, this means that you don't have to embed SQL strings in your code anymore. Instead, a query language will be built into C#. For XML programmers, this means that you don't have to learn XPath, instead, a query language will be built into C#. You can, of course, continue to use any technology that you prefer, or any combination of technologies that seems optimal in a particular case. But LINQ is now built into the C# language and offers a native solution.

A wide variety of data sources will now be accessible through LINQ. You can use it to retrieve data from an array, or from a collection, or from any data source that supports IEnumerable or IQueryable. You can even query your own program and ask how many of its methods are public, or which classes reside in a particular namespace.

LINQ can, at least in theory, be part of any .NET language. For now, that means primarily C# and VB, but there has been talk of integrating LINQ into other languages, such as PHP and Python. LINQ will be released as part of the Orcas version of Visual Studio. At the time of this writing it is available in various Microsoft CTP's, and of course it will be part of the Orcas beta when it ships.

LINQ in Action

It's time to take a peak at the LINQ syntax as it appears in the May CTP. Note that LINQ is still under development and the syntax is still undergoing minor modifications. But for now, I strongly recommend installing the May CTP and taking LINQ out for a spin.

The code shown in Listing Two demonstrates a somewhat unorthodox way to use LINQ to query an array of string. I say it is unorthodox because I sidestep a few common LINQ idioms in order to write code that will look as familiar to you as possible. In future posts, I will talk more about the preferred way to write LINQ queries, but for now I want to limit the number of new ideas I introduce in this first pass over the subject.



este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:

http://blogs.msdn.com/charlie/archive/2006/10/29/technical-links-to-li...




Subscribe News RSS  Subscribe News Updates by E-mail





myNews <myNews show="rand" cat="programacao" ⁄>

RouterJs: easy routing for your ajax Web applications new ...

RouterJs is a simple router for your ajax web apps. It's build upon History.js which means that Rout (...)

clicks: 16602 16602 2012-05-14 2012-05-14 goto url (new window) haithembelhaj.g... goto myNews programacao


Backbone computed properties new ...

This gist shows one way to implement read- and write-enabled computed properties on a Backbone Model (...)

clicks: 16432 16432 2012-05-13 2012-05-13 goto url (new window) https://gist.gi... goto myNews programacao


Android Query new ...

Android-Query (AQuery) is a light-weight library for doing asynchronous tasks and manipulating UI el (...)

clicks: 16625 16625 2012-05-12 2012-05-12 goto url (new window) code.google.com... goto myNews programacao


Create Instagram Filters With PHP new ...

In this tutorial, I'll demonstrate how to create vintage (just like Instagram does) photos with PHP (...)

clicks: 16166 16166 2012-05-12 2012-05-12 goto url (new window) net.tutsplus.co... goto myNews programacao


HTML5 jQuery Paint Plugin new ...

Websanova Paint is a HTML5 canvas based jQuery plugin. It allows you to free paint on a canvas area (...)

clicks: 27243 27243 2012-05-12 2012-05-12 goto url (new window) websanova.com/t... goto myNews programacao


Sass vs. LESS vs. Stylus: Preprocessor Shootout new ...

CSS3 preprocessors are languages written for the sole purpose of adding cool, inventive features to (...)

clicks: 15837 15837 2012-05-11 2012-05-11 goto url (new window) net.tutsplus.co... goto myNews programacao


Real-time Applications With Node.js and Socket.IO new ...

Hey everyone! Sorry about the long pause since the last blog post, life has been quite hectic for th (...)

clicks: 16533 16533 2012-05-11 2012-05-11 goto url (new window) codingcookies.c... goto myNews programacao


15 Handpicked jQuery Drop Down Menus Tutorials new ...

Here we are presenting another brilliant collection of 15 jQuery navigation menu that you can downlo (...)

clicks: 15561 15561 2012-05-10 2012-05-10 goto url (new window) smashingapps.co... goto myNews programacao