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