Linq inserting double records to the table RRS feed

  • Question

  • Hi All,

    I have a ViewModelA from where I'm sending message to ViewModelB to execute method with linq (placed in ViewModelB).

    I'm using here MVVM Light Messenger, but I have implement wrapper:

    Public NotInheritable Class GetIDMain
        Public Shared Sub Send(getId As String)
            Messenger.[Default].Send(getId, SendToExecute.GetIDMain)
        End Sub
        Public Shared Sub Register(recipient As Object, action As Action(Of String))
            Messenger.[Default].Register(recipient, SendToExecute.GetIDMain, action)
        End Sub
    End Class

    GetIDMain.Send is called from ViewModelA.

    In ViewModelB I'm registering this as: 

    GetIDMain.Register(Me, AddressOf getAi)

    My method:

    Public Sub getAi()
        Using entityconn As New TimerConn()
            Dim result As New tbl_Main_Timer() With {
                .FirstActivity = "Test1",
                .Enumber = "21385650",
                .Manager = "JD VC"}
        End Using
    End Sub

    I've noticed that in the table I have duplicated records (different ID (withPK)). So, I think that this method, or entire message is executed twice.  I was trying to implement Cleanup() or Unregister, but still - I'm getting duplicates here.

    What is causing this? Am I missing something? Message is registered on ViewModelB under the constructor...I think that the problem. But I would like to ask you for any comment on that.

    Thank you in advance.

    Tuesday, June 16, 2015 5:00 PM


All replies