Insert
NorthwindDataContext db = new NorthwindDataContext();
var newCustomer = new Customer
{
CustomerID = "MCSFT",
CompanyName = "Microsoft",
ContactName = "John Doe",
ContactTitle = "Sales Manager",
Address = "1 Microsoft Way",
City = "Redmond",
Region = "WA",
PostalCode = "98052",
Country = "USA",
Phone = "(425) 555-1234",
Fax = null
};
db.Customers.InsertOnSubmit(newCustomer);
db.SubmitChanges();
Delete
OrderDetail orderDetail =
db.OrderDetails.First
(c => c.OrderID == 10255 && c.ProductID == 36);
db.OrderDetails.DeleteOnSubmit(orderDetail);
db.SubmitChanges();
Update
Customer cust =
db.Customers.First(c => c.CustomerID == "ALFKI");
cust.ContactTitle = "Vice President";
db.SubmitChanges();
var q = from p in db.Products
where p.CategoryID == 1
select p;
foreach (var p in q)
{
p.UnitPrice += 1.00M;
}
db.SubmitChanges();