Tuesday, 16 October 2012

c sharp classes

USING LINQ TO SQL:

nwind.Northwind db = 
  new nwind.Northwind(@"Data Source=.\SQLEXPRESS;Initial Catalog=Northwind");


db.Log = Console.Out;

var custs = from c in db.Customers
            where c.Region == "WA"
            select new { Id = c.CustomerID, Name = c.ContactName };

foreach (var cust in custs)
{
  Console.WriteLine("{0} - {1}", cust.Id, cust.Name);
}

No comments:

Post a Comment