1

我在 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 工作正常...

4

1 回答 1

0

好的,我发现了我的新手错误。原来,我忘了补充:

NotifyPropertyChanging("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
于 2014-03-31T16:52:25.470 回答