Data Transformations with LINQ (C#)

Language-Integrated Query (LINQ) is not only about retrieving data. It is also a powerful tool for transforming data. By using a LINQ query, you can use a source sequence as input and modify it in many ways to create a new output sequence. You can modify the sequence itself without modifying the elements themselves by sorting and grouping. But perhaps the most powerful feature of LINQ queries is the ability to create new types. This is accomplished in the select clause. For example, you can perform the following tasks:

* Merge multiple input sequences into a single output sequence that has a new type.
* Create output sequences whose elements consist of only one or several properties of each element in the source sequence.
* Create output sequences whose elements consist of the results of operations performed on the source data.
* Create output sequences in a different format. For example, you can transform data from SQL rows or text files into XML.