首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Windows Mobile >

wp7 数据库更新操作,该怎么解决

2012-03-11 
wp7 数据库更新操作请问 wp7 进行某一行的更新的时候 有哪些方法呢。在网上查到public bool UpdateData(MyT

wp7 数据库更新操作
请问 wp7 进行某一行的更新的时候 有哪些方法呢。
在网上查到
  public bool UpdateData(MyTable source, MyTable dest)
  {
  try
  {
  var tables = from item in this.Items where (int)item.Index == source.Index select item;

  foreach (MyTable mt in tables)
  {
  mt.Name = dest.Name;
  mt.Age = dest.Age;
  mt.Gen = dest.Gen;
  break;
  }

  MyTable table = _DB.Rows.GetOriginalEntityState(source);
  table.Name = dest.Name;
  table.Age = dest.Age;
  table.Gen = dest.Gen;
  _DB.SubmitChanges();
  }
  catch (Exception e)
  {
  return false;
  }

  return true;
  }

但是我认为

  foreach (MyTable mt in tables)
  {
  mt.Name = dest.Name;
  mt.Age = dest.Age;
  mt.Gen = dest.Gen;
  break;
  }
这段代码是没有用的

[解决办法]
没看明白这代码怎么做到更新的。

你可以看一下mvvm

热点排行