StaticStringDictionary - Fast Switching with LINQ revisited

September 2, 2008 01:09 by admin

The Code Beside blog has a StaticStringDictionary implementation using LINQ expression trees.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

ForEach, a simple but very useful extension method

August 21, 2008 01:24 by admin

Glenn Block has an implementation of ForEach for IEnumerable:

  1: public static class IEnumerableUtils {
  2:   public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action) {
  3:     foreach(T item in collection) {
  4:     action(item);
  5:   }
  6: }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Find Duplicates Using LINQ

August 21, 2008 01:18 by admin

Eric White has a post on finding duplicates using LINQ.  Here is the sample:

  1: int[] listOfItems = new[] { 4, 2, 3, 1, 6, 4, 3 };
  2: 
  3: var duplicates = listOfItems
  4:     .GroupBy(i => i)
  5:     .Where(g => g.Count() > 1)
  6:     .Select(g => g.Key);
  7: 
  8: foreach (var d in duplicates) {
  9:     Console.WriteLine(d);
 10: }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

List of LINQ Prividers

July 14, 2008 00:46 by admin

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

LINQ to Water

May 22, 2008 09:16 by admin

Well, not really, but The Great LINQ shows a usage of LINQ to Objects over a chemistry domain:

 

from atom in molecule.Atoms
where atom.Element == Element.Hydrogen
and atom.Bonds.Count == 1
from atom2 in atom.Bonds[0].FindAtom(a => a != atom && a.Element == Element.Oxygen)
where atom2.FindBonds(b => b != atom.Bonds[0]).Count == 1
select atom2.FindBonds(b => b != atom.Bonds[0])[0].FindAtom(a => a != atom2)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

7 tricks to simplify your programs with LINQ

May 22, 2008 01:06 by admin

Igor Ostrovsky has a post about 7 tricks to simplify your programs with LINQ.

#1 is pretty cool:

int[] a = Enumerable.Repeat(-1, 10).ToArray();
int[] b = Enumerable.Range(0, 10).ToArray();
int[] c = Enumerable.Range(0, 10).Select(i => 100 + 10 * i).ToArray();

I disagree with #2 - it has serious performance implications.  Go check out the link to see them all...


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Using LINQ's DataContext to Recreate your Database for Testing

May 22, 2008 01:01 by admin

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Using let in LINQ to Objects

May 22, 2008 00:58 by admin

In my opinion the let keyword is one of the most power features of LINQ.  Stuart Leeks posts about using let in LINQ to objects.

 

var query = from fileSystemInfo in fileSystemInfos
        where fileSystemInfo is FileInfo
        let fileInfo = (FileInfo)fileSystemInfo
        where fileInfo.Length < 1000
        select fileInfo;

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Linq to Sql support added to LLBLGen Pro

May 1, 2008 12:24 by admin

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Putting LINQ queries together, one piece at a time

May 1, 2008 12:22 by admin

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5