LINQ, Entity Framework, and Project Astoria by Jonathan Carter
(Sep 20 2007 - 07:22:59 PM
by Timothy Khouri
) - [print blog
Last night I attended the Sarasota .NET Developers Group monthly meeting and got to hear another great talk by Jonathan Carter (who has also spoken at the Tampa and Jacksonville code camps recently). Most of the talk was spent on LINQ, starting off with LINQ to Objects and then building from there into LINQ to SQL, and even more impressively, LINQ to Entities (and the Entity Framework).
As I've been using LINQ for a little while now (and since I've already heard an earlier talk by Jonathan on that subject in Tampa, Florida), I didn't think I would learn much more on that subject. But of course, I did.
LINQ to Mindset
One of the points that was stressed was that LINQ allows you to have a different mind set about how to "query" information. Jonathan brought out the fact that most people think of SQL when they hear LINQ. This kind of "pigeon hole" is reflected by a recent poll that was taken on this site. It showed that about 30% of developers are still leery of LINQ, and the biggest reason for that is the mentality that this is another SQL.
A few examples that he showed that take your mind off of LINQ to SQL were querying against the file system and against open processes (very interesting). Here is the gist of the first one:
var myLocalXmlFiles = from currentFile in Directory.GetFiles(@"C:\someFolder")
where Path.GetExtension(currentFile) == "xml"
This is a very un-traditional way of thinking of a query, but that's the beauty of LINQ. Now, you might say that the System.IO.Directory class already has a way of returning a list of files with a certain extension, and that's true. But the beauty here is that you don't have to know of specialized functions that do standard query operations. And also, this next example has no better way of achieving the desired results:
var myProcesses = from dah_current_process in Process.GetProcesses()
orderby dah_current_process.BasePriority descending
Name = dah_current_process.ProcessName,
Instance = dah_current_process
That example above uses the new "annonymous types" that are in both C#-3 and VB-9 (.NET framework 3.5). Almost all of his examples used some sort of new feature from Visual Studio 2008. He mentioned that he's going to try to put his powerpoint material and some samples up on his site (which is still heavily under construction). Here's the link, I don't know if it's ready yet: Lost In Tangent
The Future With Astoria
Another topic that he discussed (briefly due to time constraints) was one of Microsoft's upcoming projects, Astoria. There wasn't much to say at this point, but what he demonstrated has huge potential. Here's a link if you'd like to see more: Astoria Online Service. If I'm not mistaken, Jonathan will be traveling to meet with some of the Astoria team to learn more... so we'll stay tuned on that.
In other exciting news, I won a full copy of Microsoft Office 2007 that night (random number generator picked me!), so I have to say my first Sarasota development group experience was a great one!