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;
using System.Collections.Generic;
using System.Query;
using System.Data.DLinq;

[Table(Name = "Products")]
class Product

public int ProductID;

public short UnitsInStock;

public int SupplierID;

public string ProductName;



Northwind : DataContext

   public Table<Product> Products;

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




   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
where p.SupplierID == x
orderby p.UnitsInStock

      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);