Why LINQ is Better than ForEach

I had a discussion today with a software architect who disagreed with me that LINQ to Objects should be used instead of foreach loops. My claim is that LINQ is better. He says that I shouldn’t make such a blanket statement, because LINQ is inefficient. I stand by my assertion. Declarative Code is Easier to [...]

Share

Tags: , ,

Read Users' Comments (0)

How to Use Let in LINQ Extension Methods

For a variety of reasons (many of which Scott Allen discusses in his wonderful LINQ course), I prefer to use extension method syntax with LINQ instead of query expression syntax. But one thing I miss is the “let” operation that allows me to compute intermediate results and store them in a new variable. This morning [...]

Share

Tags: , , ,

Read Users' Comments (0)

How to Use Custom Grouping in LINQ

You can use LINQ to write queries that perform grouping of data using group by or ordering of data using orderby clause. LINQ provides the default (and the most common) implementation of both of the operations, but sometimes you may need a slightly different behavior when grouping or ordering data (this article is motivated by [...]

Share

Tags: , , ,

Read Users' Comments (0)

How to Implement Paging with LINQ

Before going into how paging is implemented with LINQ, Let’s discuss the need for implementing paging. With large amounts of data, it is not a good practice to pull all records from database when you are showing a fraction of them in one page. It is always recommended to use data on demand approach. When [...]

Share

Tags: , ,

Read Users' Comments (0)

LINQ ToLookup vs ToDictionary

Some people are not sure of the difference between ToLookup vs ToDictionary LINQ methods. To break it down real simple: One is a look up (ToLookup) One is a dictionary (ToDictionary) Duh – that’s what you’re probably thinking. The real difference is understanding what each of these data structures do. Lookups A lookup is a [...]

Share

Tags: , , ,

Read Users' Comments (0)

Implementing LINQ on the .NET Micro Framework

The .NET Micro Framework, a variant of .NET radically scaled down for embedded systems, does not include the System.Linq namespace and does not provide any LINQ functionality. Because its implementation is based on generics, LINQ requires version 2.0 of the CLR. The Micro Framework on the other hand is restricted to the CLI, a standardized [...]

Share

Tags: , , , ,

Read Users' Comments (0)

How to Use .Except with EqualityComparer

Today we’re going to cover an advanced scenario where we need to compare lists of a class we created. We’ll start with an implementation of EqualityComparer<T> which consists of overriding two methods: Equals and GetHashCode. What was a little tricky about this implementation is this subtle, but critical, comment in the code sample on MSDN [...]

Share

Tags: , , , , , ,

Read Users' Comments (1)

Guidelines and Best Practices in Optimizing LINQ

Language Integrated Query (LINQ) is a query execution pipeline for use in the managed environment of .NET Framework. In essence, LINQ is Microsoft’s object relational mapper between your business objects and the underlying data sources and provides a simplified framework for accessing relational data in an object-oriented fashion. Although LINQ is great in the sense [...]

Share

Tags: , ,

Read Users' Comments (1)

Why You Need to Know LINQ to XML

In .NET 3.5, the primary device for general processing of XML is LINQ To XML. This provides a lightweight, LINQ-friendly DOM along with a set of query operators. In SiIlverlight, this is your only choice – XmlDocument and related classes are not supported. Even without its LINQ support, the LINQ To XML DOM is valuable [...]

Share

Tags: , , , ,

Read Users' Comments (0)

Generic Delegates and Lambda Expressions

Generic delegates and lambda expressions underpin LINQ. If you’ve been struggling to get your arms around these new concepts, this post should help demystify matters for you. Of course, there are a a host of other new .NET language features that enable LINQ as well. These include extension methods, type inference, anonymous types, object initializers, [...]

Share

Tags: , , , , ,

Read Users' Comments (0)

 Page 1 of 2  1  2 »