读书人

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

发布时间: 2012-03-11 18:15:39 作者: rapoo

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

读书人网 >Windows Mobile

热点推荐