创建 DataContext 对象
var dc = new NorthwindDataContext()
{
Log = Console.Out
};
插入数据
var product = new Product { ProductName = "Product Name" };
db.Products.InsertOnSubmit(product);
db.SubmitChanges();
更新数据
product.ProductName = "New Product Name";
db.SubmitChanges();
删除数据
dc.Products.DeleteOnSubmit(product);
dc.SubmitChanges();
更多关于这方面的内容,请参考 Linq to SQL 相关文档。地址:
http://msdn.microsoft.com/en-us/library/bb882674.aspx