LINQ

| No Comments
I got to use LINQ for the first time in a project today. I spend a lot of time writing SQL queries, so the ability to query pretty much anything using a SQL-like grammar is pretty appealing. I haven't had a chance to use it until now because our main application is written in C# 2.0 and we haven't had the time to see what's going to blow up if we change platforms. I'm working on something new though, so that didn't apply.

It took me some googling to figure out exactly how to do it, but what I need isn't very complex so the learning curve wasn't too steep. If you're querying a list of objects, there's some machinations to do if your list doesn't implement IQueryable, but other than that if you know SQL, you should be able to figure out the basics of querying fairly quickly.

I couldn't help but think, you know self, we could have done in this in 2 minutes with a foreach loop, and it does appear that your list has to implement IEnumerable so I suspect it basically does that under the covers.

Still, I'm thinking about some of my previous projects and how much cleaner they would be using LINQ. I don't think performance would be much different given that it's still looping through everything, but the code should be a lot faster to write and maintain.


Leave a comment

About this Entry

This page contains a single entry by foo.c published on February 25, 2010 9:47 PM.

Dynamic Inertia was the previous entry in this blog.

Sighting In, Testing, Practice is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.