Day Dreaming

"A daydream is a visionary fantasy experienced while awake, especially one of happy, pleasant thoughts, hopes or ambitions."[Ref:Wikipedia]

Day 8-12 : Chapter 14: Introduction to LINQ

Hey Guyz..really trailing my original plan and way lot to cover...As also I have been swamped with my other things..its really getting tough..but will give it my best..and go into overdrive mode now. Anyways..moving on with the book..we have next LINQ-
LINQ is Language Integrated Query. LINQ is a set of related technologies that attempts to provide a single, symmetrical manner to interact with diverse forms of data. As explained LINQ can interact with any type implementing the IEnumerable<T> interface, including simple arrays as well as generic and non generic collections of data.
The LINQ API is an attempt to provide a consistent, symmetrical manner in which programmers can obtain and manipulate “data” in the broad sense of the term. Using LINQ, we are able to create directly within the C# programming language entities called query expressions. These query expressions are based on numerous query operators that have been intentionally designed to look and feel very similar (but not quite identical) to a SQL expression.
LINQ query expressions is that they are not actually evaluated until you iterate over their contents. Formally speaking, this is termed differed execution.
When you wish to evaluate a LINQ expression from outside the confines of foreach logic, you are able to call any number of extension methods defined by the Enumerable type to do so. Enumerable defines a number of extension methods such as ToArray<T>(), ToDictionary<TSource,TKey>(), and ToList<T>(), which allow you to capture a LINQ query result set in a strongly typed container.
The OfType<T>() method is one of the few members of Enumerable that does not extend generic types. When calling this member off a nongeneric container implementing the IEnumerable interface (such as the ArrayList), simply specify the type of item within the container to extract a compatible IEnumerable<T> object.
You can also use Lambda operators for building queries. For e.g. –
var subset = currentVideoGames.Where(game => game.Length > 6).OrderBy(game => game) .Select(game => game);
General Syntax for LINQ Query - var result = from item in container select item;
LINQ query expressions can return any number of result sets, it is common to make use of the var keyword to represent the underlying data type. As well, lambda expressions, object initialization syntax, and anonymous types can all be used to build very functional and compact LINQ queries. More importantly, you have seen how the C# LINQ query operators are simply shorthand notations for making calls on static members of the System.Linq.Enumerable type.
As shown, most members of Enumerable operate on Func<T> delegate types, which can take literal method addresses, anonymous methods, or lambda expressions as input to evaluate the query.

0 comments: