Continuing with my series "SubSonic versus LinqToSQL", here I'm going to compare a simple update using the Northwind database.
If you are looking for other posts in this series, here is the list:
Here is a Simple Update while using SubSonic:
using SubSonic;
using MyCustomDAL;
...
protected void UpdateProduct(ProductID)
{
Product p = new Product(int ProductID)
p.ProductName = txtProductName.Text;
p.UnitPrice = double.Parse(txtUnitPrice.Text);
p.Save();
}
And here is a Simple Update while using LinqToSQL:
using System.Linq;
...
protected void UpdateProduct(int ProductID)
{
NorthwindDataContext db = new NorthwindDataContext();
Product p = (from products in db.Products
where products.ProductID == ProductID
select products).FirstOrDefault();
p.UnitPrice = 0;
p.Discontinued = true;
db.SubmitChanges();
}
As you can see there are some similarities as there are also differences. I encourage everyone to look into what those differences are to better prepare your programming toolset for jobs that lie ahead. :)



