Chapter 11: Deploying Web Services with WCF

311

return customer;

}

public List<Customer> GetCustomers()

{

var ctx = new MyShopDataContext();

return

(from cust in ctx.Customers select cust)

.ToList();

}

public int InsertCustomer(Customer cust)

{

var ctx = new MyShopDataContext();

ctx.Customers.InsertOnSubmit(cust);

ctx.SubmitChanges();

return cust.CustomerID;

}

public void UpdateCustomer(Customer cust)

{

var ctx = new MyShopDataContext();

var customer =

(from cst in ctx.Customers

where cst.CustomerID == cust.CustomerID select cst)

.SingleOrDefault();

if (customer != null)

{

customer.Age = cust.Age; customer.Birthday = cust.Birthday; customer.Income = cust.Income; customer.Name = cust.Name;

ctx.SubmitChanges();

}

}

Page 334
Image 334
Microsoft 9GD00001 manual 311