LINQ
LINQ
- Language Integrated Query (LINQ)
- Language-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# language.
- With LINQ, a query is a first-class language construct, just like classes, methods, events.
- You write queries against strongly typed collections of objects by using language keywords and familiar operators.
- The LINQ family of technologies provides a consistent query experience for objects (LINQ to Objects), relational databases (LINQ to SQL), and XML (LINQ to XML).
- By using query syntax, you can perform filtering, ordering, and grouping operations on data sources with a minimum of code.
- You use the same basic query expression patterns to query and transform data in SQL databases, ADO.NET Datasets, XML documents and streams, and .NET collections.
- LINQ in C#
- You can write LINQ queries in C# for SQL Server databases, XML documents, ADO.NET Datasets, and any collection of objects that supports IEnumerable or the generic IEnumerable
interface. - LINQ support is also provided by third parties for many Web services and other database implementations.
- You can write LINQ queries in C# for SQL Server databases, XML documents, ADO.NET Datasets, and any collection of objects that supports IEnumerable or the generic IEnumerable
Code
- Program.cs
LINQ Syntax
- from … in
- seems like foreach
- where
- seems like filter
- search data wich is true in condition
- orderby
- seems like sorting
- default is ascending
- You can change ascending or descending
- select
- make the result
- You can make ananymous object to select
- group … into
- make a group
- join … in … on
- join two tables with condition