.NET
  Home arrow .NET arrow An Introduction to LINQ
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

An Introduction to LINQ
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2008-06-09

    Table of Contents:
  • An Introduction to LINQ
  • VB.NET
  • Implicitly Typed Variables and Anonymous Types
  • More Standard Query Operators

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    An Introduction to LINQ


    (Page 1 of 4 )

    If you're looking for a way to simplify data manipulation in .NET, you may want to check out what LINQ has to offer. It adds some very useful capabilities to .NET. Keep reading for a full overview. This article is the first of two parts.

    Programming involves data manipulation; it involves pulling different pieces of information from different sources. One might pull headlines from an RSS feed, query a relational database, or loop over a collection of objects, extracting elements that meet a given condition. Each one of these tasks involves somehow querying a given data source and then turning that data into something useful, but the exact method involved can vary widely. The method may be simple, but, then again, the method may also be more involved, as in querying a database. Still, the overall goal is the same, so why not unify the means to that end?

    This is what LINQ, which stands for Language Integrated Query, aims to do. LINQ adds query syntax (similar to SQL, but native) and capabilities to .NET. Using LINQ, one can query a variety of data sources in a unified, easy way. Moreover LINQ contributes to readability, since someone browsing code can easily identify a query and determine what it does. This article will provide an overview of LINQ, its structure and its capabilities, using both C# and VB.NET.

    Query Syntax

    LINQ adds queries right into the language through new syntax. The syntax is similar to SQL, so it should be familiar to most developers. A query provides the developer with a concise way to say (at the risk of making LINQ seem simplistic), select all the elements where a certain condition is met.

    For example, let's say that we have a class, Person, that represents, well, a person, and that for each person, we need to know a name, an age and a phone number. In C#, we can represent this as follows:


    class Person

    {

     string name;

     int age;

     string phone;


     public Person(string name, int age, string phone)

    {

     this.name = name;

     this.age = age;

     this.phone = phone;

    }


     public string Name

    {

     get

    {

     return name;

    }

    }

     public int Age

    {

     get

    {

     return age;

    }

    }

     public string Phone

    {

     get

    {

     return phone;

    }

     }

    More .NET Articles
    More By Peyton McCullough


       · Hello, all,This article is the first of two articles intended to be an...
     

    .NET ARTICLES

    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT