So finally the gauge is off.
I'm going to publish a sets of blogs about a language feature that will be introduced in C# 3.0. Codename for this project is LINQ or Language Integrated Query.
In this first blog I'll basically introduce LINQ as a subject and in later posts I will drill down on different features.
LINQ is trying to address two general problem domains, the first is the idea that data usually isn't objects. Traditionally all data is saved in some kind of relational store (I know there's a lot of you out there that uses object stores but I'm ignoring you for now ;), relational data is built up of rows and columns and doesn't neccesarily materialize easily into an object.
The second general problem domain is consistency. We usually have loads of ways to write logic that selects or transfers data from one place to another. Some of the solutions doing this is really slick, others are (eh) not so slick.
So LINQ will try to solve these two (and many other) issues. Let's start of with a typical LINQ code bit;
var data = from m in typeof(string).GetMembers()
select m.Name;
This will effectively give us a IEnumarable containing the names of strings all members. Since it's an IEnumarable it will easily get iterated over in all ways we can use it.
So what! You might say, "That's hardly revolutionary!". Well no, this is no revolution, just simplification for us as developers. Instead of having to write this code manually, we'll get som help of the compiler and the clr.
To demonstrate the power some more:
var data = from m in typeof(string).GetMembers()
order by m.Name
select m.Name
Well the SQL like syntax will tell you alot about what that will give us. Yes, that's right. An ordered list of member names. Now check this out as well:
var data = from m in typeof(string).GetMembers()
order by m.Name
where m.MemberType == MemberTypes.Field
select m.Name
And I can go on and on. There's about 30 of theese standard operators defined in the C# 3.0 specs including billboard hits like top, skip, group by etc.the
So how does all of this fit together? Read on as I'll introduce the techniques and methods used to make this all possible. In further posts I will be talking about lambda expressions, type extensions and anonymous types.
|