Daily Archives: March 2, 2007

MIX07!

The stars have aligned and I’m going to MIX07.

I am ignoring the fact that this is going to mean a whole lot of flying . In a 5 week period I will fly to Orlando and back (from Vermont), then to Seattle and back and then to Las Vegas and back. Oy, silly me.

 

A few of the many syntax changes in VB (and Linq for SQL queries)

VB9 has come a long way in the new March CTP of Orcas! Paul Vick has a quick list of what is now in there. And there are a lot of good details in the msdn documentaiton that comes along with the CTP.

A few things I noticed quickly when bringing my LINQ for SQL demos over to the new bits.

  • First, and happily, the named parameter syntax of := is no longer necessary. You can just type =, like a normal person.
  • You need to be explicit about using the reference to the entity when refering to properties. In other words where I could say
     From s In db.Suppliers_
                Where CompanyName = “Exotic Liquids” …
    I now need to put  “s.” in front of the CompanyName property
  • The anonymous types have been fleshed out more and you need to use the With keyword when creating one.
  • Also in the anonymous types, when you are definining a new named parameter, you need the “.” in front of that parameter, so it is obviously a property of the anonymous type.
  • Maybe this isn’t the ultimate way to do it, but it seems that if you want to further leverage one of the properties of that anonymous type, eg to order on, then you need to name the anonymous type and reference it in the order by clause. Again, maybe this isn’t THE way, but it’s the way I got my code working again.

Here’s a before (as in earlier CTP) and an after (March CTP) example of a simple query that does all of these things.

OLD
From s In db.Suppliers _
            Select New {Company := CompanyName, Country, Products}

NEW
From s In db.Suppliers _
            Select New With {.Company = s.CompanyName, s.Country, s.Products}

Here’s what it looks like with a nested query
  From s In db.Suppliers _
            Select New With {.Company = s.CompanyName, s.Country, _
            .Products = (From p In s.Products _
                Select New With {p.ProductName})}

OLD with Order By
From s In db.Suppliers _
            Select New {s.CompanyName, s.Country, s.Products} _
            Order By CompanyName

NEW with Order By
  Dim mylist = From s In db.Suppliers _
            Select s2 = New With {s.CompanyName, s.Country, s.Products} _
            Order By s2.CompanyName

I’ve seen samples where “s” has been used for both the reference to the items in the db.suppliers collection AND to the name of the new anonymous type. That scares me, so I used a new variable (s2).

There is also a whole new set of query samples in the MSDN documentation.

Powder day schmowder day

Yesterday I proclaimed that today would be a powder day – regardless of how much work I have to do. We had a forecast of 7-12 inches of new snow.

The promised snow started before we went to bed last night.

But when I woke up in the middle of the night to a howling wind and then again this morning to the same, I knew it would be another productive day in front of the computer. It’s wild out there. Rich is still heading out to the ski hill. He’s insane. I certainly wouldn’t want to be sitting in the chair lift in this weather.

It’s what he refers to as a “character building day.” That’s an old joke from when he worked for a builder that, even in the winter, had his crew arrive at 6am and work until 4pm. Even when it was 5 degrees out and all then ended up doing was shoveling snow out of the foundation. I’d last about five minutes in a job like that. Give me my cozy office chair any day! 🙂