LINQ to SQL Deep Learning Series Four LINQ query Basics

Source: Internet
Author: User
Tags web services visual studio

Part of this article is organized from MSDN

First, the Concept of LINQ:

LINQ is the abbreviation for Language Integrated query (language integration queries), which is integrated in the. NET programming language, which makes query expressions good at compile-time syntax checking, rich metadata, IntelliSense, and other strongly typed languages. Linq is a groundbreaking innovation in Visual Studio 2008 and the. NET Framework version 3.5. It has a bridge between the object domain and the data domain.

Second, the background of the Emergence of LINQ:

Traditionally, queries for data are represented in simple strings, without compile-time type checking or IntelliSense support. In addition, you must learn different query languages for the following data sources: SQL databases, XML documents, various WEB services, and more. LINQ makes queries a first-class language construct in C # and Visual Basic. You can write queries against a collection of strongly typed objects using language keywords and familiar operators. In Visual Studio, you can use visual Basic or C # to write LINQ queries for the following data sources: SQL Server database, XML document, Ado.net DataSet, and support for IEnumerable or generics Ienumera Ble<t>) interface to a collection of arbitrary objects. In addition, LINQ support for the Ado.net Entity Framework is planned, and third parties write LINQ providers for many WEB services and other database implementations.

Third, query expression resolution:

Query resolution Instance

int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };//获取数据源。
  var lowNums = from n in numbers
                where n < 5
                select n;            //创建查询。
   Console.WriteLine("Numbers < 5:");
   foreach (var x in lowNums)            //执行查询
   {
          Console.WriteLine(x);
   }

The results are:

Numbers < 5:
4
1
3
2
0

Queries that are semantically equivalent to the following method style

 var lowNums = numbers
               .Where(s => s < 5)
               .OrderBy(s => s)
               .Select(s => s);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.