Continuing the series, SubSonic versus LinqToSQL, this example shows a simple delete using SubSonic and then the equivalent using LinqToSQL. It is worth to note that SubSonic has two ways to delete records, on just updates a bit field called "IsDeleted" and essentially turns the record "off" while the "Destroy" method actually deletes the record.
If you are looking for other posts in this series, here is the list:
Here is the simple delete using SubSonic:
using SubSonic;
using MyCustomDAL;
...
protected void DeleteProduct(int ProductID)
{
Product p = new Product(ProductID)
p.Destroy();
}
And here is the simple delete using LinqToSQL:
using System.Linq;
...
protected void DeleteProduct(int ProductID)
{
NorthwindDataContext db = new NorthwindDataContext();
Product p = (from products in db.Products
where products.ProductID == ProductID
select products).FirstOrDefault();
db.Products.DeleteOnSubmit(p);
db.SubmitChanges();
}



