Delete a row

If you want to delete a row from database, just load the row and then tell the data context to delete the row. Row will be deleted when changes to the data context are submitted back.
using (var ctx = SqlDataContext.CreateContext()) {
    Customer cu = ctx.Load<Customer>(query => query.CustomerID = 1);
    ctx.Delete(cu);
    ctx.SubmitChanges();
}


Next chapter: Define generated properties

Last edited Oct 26, 2010 at 9:51 AM by nolics, version 2

Comments

No comments yet.