Simplify with Linq

Takes simple tasks and makes them so brutally clean.  Simple examples…

int [] i = { 1, 3, 5, 6,7, 9 };
int  [] i2 = { 2, 4, 5, 8, 10, 3, 5 }; 

 // Combination of all (repeats included).
IEnumerable<int> concat = i.Concat(i2).ToList();

// Only those ints from i not in i2.
IEnumerable<int> except = i.Except(i2).ToList(); 
  // Only the unique ints found in i and i2, and order them.
IEnumerable<int> union = i.Union(i2).OrderBy(r => r).ToList();
  // Only those ints that exist in both i and i2.
IEnumerable<int> intersect = i.Intersect(i2).ToList(); 

linq, auto properties, all the goodies boost productivity

I’m working on a little side-project for a former co-worker.  Its a small project, and I’m working on the back-end using asp.net 3.5.  I don’t know if its Linq, or Linq-to-sql, or the automatic properties, or improved VS productivity tidbits (and enhanced intellisense), but I just find myself moving quickly with great productivity on projects like this. 

Case in point.  I had to snag some data out of the database in a flat manner, and present it in a grouped manner.  Instead of having to group the data up myself, I just used Linq’s GroupBy() support and formed my data into the shape I needed (this was to allow clean data-binding with nested DataLists without going to the db more than once).

Ok, I’m rambling, but while asp.net 3.5 was considerably smaller than 2.0 in size/scope, it just seems to fit right.  So, props to Microsoft.

(Don’t worry, we’ll have more than enough complaints when it comes to other things…. like Moss).