MyDatatBaseDataContext MyDB = new MyDatatBaseDataContext();
var _Update = from u in MyDB.Employees where u.Address == "WestSreet" select u;
foreach (var item in _Update)
{
item.Address = "WS";
}
MyDB.SubmitChanges();
var Select = from s in MyDB.Employees select s;
grd_1.ItemsSource = Select;
使用上面的代码,我可以更新记录,我也可以在原始表数据和 DataGrid 中看到记录修改。原始表已成功更新。
MyDatatBaseDataContext MyDB = new MyDatatBaseDataContext();
var _Udate_2 = MyDB.Employees.Where(u => (u.Address == "WestSreet"));
foreach (var item in _Udate_2)
{
item.Address = "WS";
}
var Select = from s in MyDB.Employees select s;
grd_1.ItemsSource = Select;
使用上面的代码,我可以更新记录。我可以在 DataGrid 中看到修改 但在原始表数据中看不到记录修改。原始表没有更新。