Understanding Lazy Evaluation in LINQ

One of the most important concepts in LINQ is the notion of lazy evaluation.  Without this facility, LINQ would perform very poorly. Query expressions operate on some type that implements IEnumerable<T>.  The variable of type IEnumerable<T> on which the query expression operates is the source of the query expression.  Further, query expressions often evaluate to [...]

Share

Read Users' Comments (0)

Quick LINQs

Today I will be sharing links from other blog's which I think have good article on using LINQ or features of LINQ.   Using LINQ with ASP.NET (LINQ to SQL) http://www.dotnetbips.com/articles/dae4e4be-6d25-49b4-a490-2b0c77854703.aspx   An older Scott Gu blog article on the LINQ extensions http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx#6425898   LINQ to Objects in the Compact Framework http://simonrhart.blogspot.com/2008/07/linq-to-objects-on-cf.html   LINQ + [...]

Share

Read Users' Comments (0)

How to Generate a Random Sequence with LINQ

Wyktor Zychla has an interesting post about generating random sequences using LINQ and Random. His goal was to simplify the process down to one line of code, and he achieves his goal quite well. The problem I noticed with his goal is his use of the Random class to generate random numbers. If you recall [...]

Share

Read Users' Comments (0)

How to Cancel Long Running LINQ Queries

I had planned to do an article on how to display the progress of a LINQ query, and how to cancel the LINQ query prematurely. But, it seems Samuel Jack beat me to it Both implementations are very simple and they are very good to illustrate how LINQ can be extended and manipulated in a [...]

Share

Read Users' Comments (0)

How to Read an XML File With LINQ to XML

It's one of the most common requirements now – read an XML file. There are several methods to opening and parsing an XML file – XPath, XQuery, and LINQ to XML to name a few. I have found that LINQ to XML makes it much easier (and faster) to read and parse an XML file. [...]

Share

Read Users' Comments (0)

LINQ Ordering Operators

LINQ comes packed with few useful ordering operators. These are: OrderBy, ThenBy, OrderByDescending and ThenByDescending. I will walkthrough these operators using an example of cities. Here is the code for City class. public class City { public string Name { get; set; } public string Country { get; set; } } Below is the intitializer [...]

Share

Read Users' Comments (0)

How to Randomly Reorder a List With LINQ

There are many times when we need to randomly sort a list or array. An example might be if you had a list of advertisements to display on your website, and need to randomly sort the list so the ads appear in random order. Another example might be if you have a card game, you [...]

Share

Read Users' Comments (0)