Tuesday, February 7, 2012

LINQ

I will add to this in the near future and provide the steps we took in SQL Server and the link designer

for now here is the LINQ code

 protected void Button1_Click(object sender, EventArgs e)
 {
   AutomartDataClassesDataContext dc = new AutomartDataClassesDataContext();
   var ourCustomers = from c in dc.RegisteredCustomers
                      orderby c.Person.LastName
                      where c.Person.LastName=="Anderson"
                      select new {c.Person.LastName, 
                            c.Person.FirstName,c.Email};

    GridView1.DataSource = ourCustomers.ToList();
    GridView1.DataBind();
 }

No comments:

Post a Comment