我在WP8中使用Linq to SQL更新项目时遇到问题。当我运行代码时,对象在通过应用程序时会得到很好的更新。但是,一旦我离开应用程序,更新就会丢失。
似乎.SubmitChanges() 不起作用。可能是什么原因?
Public Sub AdjustTile(ByVal thisTile As TileObject, ByVal info As Integer)
Dim query = From row As TileObject In tileDb.TileTable
Where row.id = thisTile.id
Select row
For Each row As TileObject In query
row.ChoosenWide = info
Next
tileDb.SubmitChanges()
End sub
函数 InsertOnSubmit 和 DeleteOnSubmit 工作正常...
好的,我想出了我的新手错误。原来,我忘了补充:
NotifyPropertyChange("ChoosenWide")和 NotifyPropertyChanged("ChoosenWide")
请参阅 http://code.msdn.microsoft.com/wpapps/Local-Database-Sample-57b1614c
感谢alsafoo & usr的帮助。
Private _ChoosenWide As Integer
<Column()>
Public Property ChoosenWide() As Integer
Get
Return _ChoosenWide
End Get
Set(ByVal value As Integer)
If _ChoosenWide <> value Then
NotifyPropertyChanging("ChoosenWide")
_ChoosenWide = value
NotifyPropertyChanged("ChoosenWide")
End If
End Set
End Property