首先在project里new一个新Item,选择LINQ to SQL Classes,然后双击进入Design View界面,在Tools->Connect to Database,把需要的Tables选上,拖拽到DesignView,vs2008就会自动生成DataClassesDataContext的所有需要的代码,最后给你几行最基本的Update的sample,在page的cs code里:
DataClassesDataContext db = new DataClassesDataContext();
Guid gID = new Guid(Request.QueryString["ID"].ToString());
var rec = db.Receivings.Single(r => r.ID == gID);
rec.ReceivingDate = Convert.ToDateTime(ReceivingDateTxt.Text);
db.SubmitChanges();
简单就是美,如果LINQ搞那么复杂就失去了其中一个很大的魅力了:)
DataClassesDataContext db = new DataClassesDataContext();
Guid gID = new Guid(Request.QueryString["ID"].ToString());
var rec = db.Receivings.Single(r => r.ID == gID);
rec.ReceivingDate = Convert.ToDateTime(ReceivingDateTxt.Text);
db.SubmitChanges();
简单就是美,如果LINQ搞那么复杂就失去了其中一个很大的魅力了:)