What is LINQ? LINQ operators?
LINQ is way to manipulate and
process collections and tables of data. These collections and tables can be in
the memory, in the database, in XML files, in Excel files, in text files and in
code. All this data is loaded in the form of in-memory object-graph on the heap
and then we perform different processing and manipulation operations on it.
These are easy and succinct way of playing with in-memory collections. Write
less and do more. It raises the level of abstraction by which we manipulate and
process collections and tables of data. Traditionally we do all this stuff with
Type specific Utility classes having Utility methods those process collections
and tables for us. LINQ is their replacement. It is an elegant way to process
collections and tables.
It is done on the on all
collections and tables to implement IEnumerable<T>.
It is done by extension methods
mechanism introduced in .net. Extension method is a static method defined in a
static class and it extends the existing classes, structs, final classes,
interfaces, abstract classes, third party classes, .net framework classes and
defined NEW METHODS ON THEM with exploiting the Inheritance and Composition.
Static methods are defined on IEnumerable<T> using the extension methods
mechanism. When we import System.LINQ, we are available with all extension
methods on the DataType those implement IEnumerable<T>. These extension methods take the Function
Pointer or Delegates those define the predicate function those define filtration
criteria or query to process or manipulate the collection or tables. Lamda
expressions are the way to express the Anonymous Delegates those passed to the
Extension Methods.
(Parameters to
extension method) => (criteria of filtration or manipulation the collection
or tables; method body of the Anonymous Delegate passed to the extension method)
50 LINQ operators are defined on the IEnumerable<T>
those are available to wide variety of collection data types.
Lamda Expression => Anonymous Delegates => These are
passed to the Extension methods defined for the IEnumerable<T>
No comments:
Post a Comment