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)