Last updated on July 10, 2019
private void InsertAndUpdate() { NorthwindDataContext db = new NorthwindDataContext(); //Insert a record Customer newCus = new Customer(); newCus.CustomerID = "YYYZZ"; newCus.CompanyName = "Company_Z"; db.Customers.InsertOnSubmit(newCus); db.SubmitChanges(); //Update a record Customer record = (from p in db.Customers where p.CustomerID == "12345" select p).SingleOrDefault(); Console.WriteLine(default(Customer)); if (record != default(Customer)) { record.CompanyName = "Company_A"; } db.SubmitChanges(); }
Be First to Comment