我在使用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函数正常工作......
答案 0 :(得分:0)
好的,我发现了我的新手错误。事实证明,我忘了添加:
NotifyPropertyChanging(“ChoosenWide”)和NotifyPropertyChanged(“ChoosenWide”)
请参阅http://code.msdn.microsoft.com/wpapps/Local-Database-Sample-57b1614c
谢谢alsafoo&我们的帮助。
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