Frage

I'm having a problem updating an item using Linq to SQL in WP8. When I run the code, the Object gets updated fine when going trough the app. However, as soon as I leave the app, the update gets lost.

It seems that .SubmitChanges() does not work. What could be the reason?

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

The functions InsertOnSubmit and DeleteOnSubmit work fine...

War es hilfreich?

Lösung

Ok, I figured out my newbie mistake. Turns out, I forgot to add:

NotifyPropertyChanging("ChoosenWide") and NotifyPropertyChanged("ChoosenWide")

See http://code.msdn.microsoft.com/wpapps/Local-Database-Sample-57b1614c

Thanks alsafoo & usr for your help.

    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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top