Language-Integrated Query (LINQ)

Source: Internet
Author: User

Language-Integrated Query (LINQ) is a series of technologies that directly integrate query functionality into the C # language. data queries have historically been represented as simple strings, with no compile-time type checking or IntelliSense support. In addition, for each data source, you also need to learn different query languages: SQL databases, XML documents, various WEB services, and so on. with LINQ, queries become the most advanced language constructs, just like classes, methods, and events.

For developers writing queries, the most obvious "language integration" part of LINQ is the query expression. query expressions are written using declarative query syntax . using query syntax, you can perform filtering, sorting, and grouping operations on the data source with minimal code. you can use the same basic query expression pattern to query and transform SQL databases, ADO. NET datasets, XML documents and streams, and data in. NET collections.

Inquire

var query = from num in numbers ...

Sort the results according to a key pair:

string[] Groupingquery = {"Carrots","Cabbage","Broccoli","Beans","Barley"};ienumerable<IGrouping<Char,string>> queryfoodgroups = fromIteminchgroupingquery Group item by item[0];
View Code

Method statements such as SUM, Max, Min, Average, and so on

list<int> numbers1 = new list<int> () { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0};

Double average = numbers1. Average ();
Double sum = numbers1. Sum ();
Double max = numbers1. Max ();
Double min = numbers1. Min ();

Language-Integrated Query (LINQ)

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.