How to Create a Tag Parser

Today's post is non-LINQ related…

Download the Tag Parsing Source Code:Tag Parser Engine.zip (6.93 kb)

Recently, I had the need to create a document with markup tags (similar to how HTML uses <b></b>, for example). I wanted a simple, easy solution for parsing out the tags in the document, something that could be easily reused.

I found one [...]

Read Users' Comments (0)

How to Use LINQ.GroupBy

LINQ query expressions intentionally look like SQL, because SQL is a non-procedural query language that many developers are already familiar with, so it gives developers a familiar frame of reference.
One of the fundamental differences between LINQ and SQL is that where SQL always projects rectangular result sets, LINQ has the capability of projecting hierarchical result [...]

Read Users' Comments (0)

How to Speed Up LINQ to Sql With Compiled Queries

One of the drawbacks of LINQ to SQL is that the SQL statement is built dynamically so it needs to be parsed and compiled each time you run it. The System.Data.LINQ namespace provides a solution in a class named CompiledQuery. This class is responsible for caching the compiled version of a LINQ to SQL query. [...]

Read Users' Comments (0)

Using Parallel LINQ

The LINQ Team at Microsoft is working on extensions to Language Integrated Query (LINQ) referred
to as Parallel LINQ (PLINQ). PLINQ makes it easy to use multiple
threads and all that processing power. This article shows you how and
provides some parameters and guidelines for when you can get some extra
horsepower out of multithreading your LINQ queries.

To Multithread [...]

Read Users' Comments (0)

SQL CE 3.5 with LINQ to SQL

Using LINQ to SQL with SQL CE 3.5 can be
a bit of a challenge.  First off, the LINQ to SQL Visual Studio
designer doesn’t support SQL CE so you need to run sqlmetal
from the command line to create the object model (or write it by
hand).  Once you get past this point then you can use LINQ [...]

Read Users' Comments (0)

Using LINQ DefaultIfEmpty to Test If an Element Exists

Often you want to run something only if an element exists. There is always the Try/Catch method, but that introduces code overhead and increases resources if the Catch block is called. LINQ provides an extension called DefaultIfEmpty which returns a default value if the item does not exist in the list. The easiest way to [...]

Read Users' Comments (0)

Using LINQ ElementAt and LINQ ElementAtOrDefault

LINQ provides two extension methods for retreiving the element at a given index in a List or other IEnumerable object. ElementAt returns the element at a given index, but can throw a System.ArguementOutOfRangeException when the specified index is a
negative value or not less than the size of the sequence. ElementAtOrDefault returns the element at a [...]

Read Users' Comments (0)