LINQ to SQL Tips and Tricks

There are many little tips and tricks for LINQ to SQL which can make our lives easier, or improve the speed and efficiency of the generated code. Below are several tips and tricks I have found during my time as a LINQ developer. *Note: Some of these tips are for querying directly from the table. [...]

  • Share/Bookmark

Read Users' Comments (0)

How to Use LINQ OfType<>

LINQ OfType<> is a useful filtering function for returning items in a collection which match a specific type (or base type). An example might be for getting base items from a listbox of combobox. An example without OfType: ColorWrapper x = combo.Items.Where( obj => obj is ColorWrapper ).Cast< ColorWrapper >().FirstOrDefault(cw => cw.Color == value); An [...]

  • Share/Bookmark

Read Users' Comments (1)

Thread Safe Generic Queue Class

I've been doing a lot of mult-threading work, recently, using the standard Thead class, the Worker Queue, and the new PLINQ (Parallel LINQ). The problem with most of the built-in generic collections (Queue<>, List<>, Dictionary<>, etc), is that they are not thread safe. I created a library of thread safe collections which allow me to [...]

  • Share/Bookmark

Read Users' Comments (0)

How to Use LINQ TakeWhile

Today I will talk about a simple and useful LINQ method called "TakeWhile". Enumerable.TakeWhile as defined on MSDN is a method that returns elements from a sequence as long as a specified condition is true, and then skips the remaining elements. To show an example use of it, I provided a sample code that retrieve [...]

  • Share/Bookmark

Read Users' Comments (0)