Database Reference
In-Depth Information
Figure 18-2. LINQ references
Now you are ready to work with a LINQ project, and all you need to do is add the code functionality
and required namespaces to the project and test the application. Let's begin using LINQ.
Using LINQ to Objects
The term LINQ to Objects refers to the use of LINQ queries to access in-memory data structures. You can
query any type that supports IEnumerable<T> . This means you can use LINQ queries not only with user-
defined lists, arrays, dictionaries, and so on, but also in conjunction with .NET Framework APIs that
return collections. For example, you can use the System.Reflection classes to return information about
types stored in a specified assembly and then filter those results by using LINQ. Or you can import text
files into enumerable data structures and compare the contents to other files, extract lines or parts of
lines, group matching lines from several files into a new collection, and so on. LINQ queries offer three
main advantages over traditional foreach loops:
They are more concise and readable, especially when filtering multiple conditions.
They provide powerful filtering, ordering, and grouping capabilities with a
minimum of application code.
They can be ported to other data sources with little or no modification.
In general, the more complex the operation you want to perform on the data, the greater the benefit
you will realize by using LINQ as opposed to traditional iteration techniques.
 
Search WWH ::




Custom Search