« Welcome to LA | Main | Information on Visual Basic 9.0 »

September 13, 2005

LINQ Revealed at the PDC

Don Box and Anders Hejlsberg just did a demo at the PDC where they showed how C# (and VB.NET) are being enhanced so that the languages contain query functionality.  There's probably a bunch of white papers going live today, but here's what the syntax looks like.

The following code gets the list of running processes by calling Process.GetProcesses.  This is then joined with information in a SQL database that has descriptions of certain processes:

ProcessDescriptionDb db = new ProcessDescriptionDb();
var query = 
	from p in Process.Getprocesses()
	where p.WorkingSet > 1024 * 1024 * 4
	orderby p.WorkingSet descending
	select new {
		Description = (
			Fom d in db.processDescriptions
			Where d.processName = p.ProcessName
			Select d.Description

foreach (var item in query)
	Console.Writeline("{0,-30}{1,10:N0} {2}", item.ProcessName, item.WorkingSet, item.Description);

Wild.  I can't wait to see some of the VB syntax.

Posted on September 13, 2005 at 12:01 PM | Permalink


The comments to this entry are closed.