/Home /Archive /Syndicate /Blog /Support /About /Contact  
All Visual Basic Feeds in one place!





  As mentioned earlier, there is a Hands On Lab available from Microsoft which walks you through some basic (and not so basic!) steps in using Linq To SQL.  The download page is here.

  Here are a few observations on the Linq To SQL Hands on Labs that I jotted down while I was working through it :

So Much Reassurance is, umm, Reassuring!
  One aspect of the Labs that I particularly liked was that the narrative was full of helpful notes to reassure me as I worked my way through it. The kind of thing included is "Note: .. the new row will not show in the results" and "Note:As in the last task, no changes have actually been sent to the database yet". I think notes at this level are extremely useful - and far too often technical authors forget that there is a wide range of understanding out there in their reading public. As they are side notes, readers who don't need the info can skim or ignore them; the rest of us can read them and be reassured that we haven't missed or misunderstood something.

So Many Customers Can Be Confusing!
  I decided that I would create a brand new Orcas project and solution for each part of the Lab. That way, I thought, I could go back later when it all became fuzzy in my memory and just home in on one particular technique. It also meant that I got a bit of learning reinforcement as I went through the initial steps again each time

  Just be aware though that in Exercises 2 and 3 (Internals) you hand-build your own Customer class (and very tricky stuff it is, too, although it is clearly explained). However, when you move on to Exercise 4 you need to revert to the Customer table from the dbml file, i.e. the one you created the easy way back in Exercise 1. If you don't, you'll have a problem or two when you try and use the demo code in Exercise 4. It's not rocket science level stuff, but may give you pause if you're not aware.

  And at the risk of insulting your intelligence, you need to add the further two Tables from Northwind - Order Details and Products - to the existing dbml file, so you eventually have all five tables available.

Some Typos and Missing Link

  It's rare day when you can work through a whole set of printed exercises and not get stung by a few typos in the code. The Linq To SQL HOL is generally pretty good on this score, but be aware that in Exercise 4, Task 2 there's a minor blip that's pretty obvious as soon as you look at it (and doesn't really undermine anything important in the learning curve). The formatted WriteLine string should of course be:

  '  Display the result
   For Each cust In CACustomers
     Console.WriteLine("{0}, {1}, {2}, {3}", _
     cust.CustomerID, cust.CompanyName, cust.ContactName, cust.Orders.Count)
   Next
i.e. the second "{2}" changed to "{3}".

  It might also be worth mentioning that if you want to see the (not yet persisted) Update to the contactname, which is what the next Task -Task 5 - does, then you should copy and paste the above block again to bottom(ish) of Sub Main. That way you'll get both versions displayed one after the other.

  I also had a problem with Tasks 1 - 4 of Exercise 5, in that I couldn't track down the SQL Server database they were using. I think this may be available via SQL Server Express or the VB Express Starter Kits, but it doesn't seem to be linked from the download page and I didn't pursue it. So, I did skip actually carrying out those tasks.   (I think it's available as part of one of the Starter Kits in VB 2005, but not included with the Orcas Beta 1 - I'm sure it will probably all come together once the final version is shipped).

Overall though, I found the whole package to be well written, clear to follow and very useful. I'm sure I'll be dipping back into it for help in the future and, with the current lack of VB based Linq articles and books, this Hands On Lab is very welcome.

© 2005 Serge Baranovsky. All rights reserved.
All feed content is property of original publisher. Designated trademarks and brands are the property of their respective owners.

This site is maintained by SubMain(), a division of vbCity.com, LLC