Code for my DLinq Demo at PDC

Here is the code for my demo during David Campbell's (DAT200, 11am Wednesday) session titled "Future Directions for Data-Driven Applications ...". Of course I don't have the video for showing the code in multiple steps starting from scratch. But here is the final code with query update etc.

You can run this with the PDC LINQ Preview bits. If you came to PDC, you have it on DVD. If not, just download it from our site. All it needs is Visual Studio 2005 beta2 with SQL Server 2005 (it is an option when you install VS beta2).

using System;

[Table(Name = "Products")]

   public int

   public short

   public int

   public string


class Northwind : DataContext

   public Table<Product> Products;

   public Northwind(string s) : base(s) { }


class Driver

   static void Main(string[] args)

      Northwind db = 
         new Northwind(@"c:\Northwind\Northwnd.mdf"

      db.Log = Console.Out;

      int x =3;

      var query = from p in db.Products
p.SupplierID == x

      select p;

      Product sauce = query.First();


      sauce.UnitsInStock += 10;



      Console.WriteLine("Post-SubmitChanges() results\n");

      foreach (var p in query)

            p.ProductID, p.UnitsInStock, p.ProductName);



Comments (5)
  1. Philippe Leybaert says:

    When you call db.SubmitChanges(), does it only generate the SQL statement to update the column [UnitsInStock], or will it update all columns?

    If only [UnitsInStock] is updated, how does the compiler/runtime know that only this field has changed? (since it is a field, and not a property with a set accessor)

  2. Dan Miser says:

    Could you clarify something? According to the description under "C# LINQ Tech Preview" on, it says "Note: this preview works only with the Visual Studio 2005 Release Candidate." We received the RC version at PDC. However, after installing RC and this LINQ Tech Preview from the web (not the one on disc 4), my LINQ projects don’t work anymore.

    To confuse matters even more, I found this snippet in C:Program FilesLINQ PreviewDocsReadMe.htm: "The prototype compilers and samples will not function on builds later than Beta 2. Note that this means you must not be running the RC0 build of Visual Studio included in the PDC kit."

    So, should I just go back to Beta 2, or will there be an update for the LINQ preview soon?


    Dan Miser

  3. Dan Miser says:

    I tried commenting before, and it didn’t take. You might want to take a look at this link for some problems with the deliverables:

Comments are closed.

Skip to main content