如何使用linq比较修改的行并更新到数据库?

时间:2013-05-15 21:51:49

标签: vb.net linq entity-framework

我正在使用asp.net处理handsontable。如果用户更改表上的数据并单击“保存”按钮。数据来自Jason格式,通过AJAX调用。然后我能够将JSON格式数据转换为List (of T)。直到我没事。

问题是我会List (Of T)但不知道修改了哪个列。那怎么可能 比较修改后的[row] [column]和数据库行,如果修改了,如何使用Entity Framework使用LINQ更新它?

 <OperationContract()>
    Public Function SaveGridData(ByVal input As String) As String 
        Dim initiativeData As List(Of InitiativeData) = JsonConvert.DeserializeObject(Of List(Of InitiativeData))(input)
        '' Update to database
        Return "ok"
    End Function

    #Region "Properties"

    Private _ClientIdx As Integer
    Public Property ClientIdx() As Integer
        Get
            Return _ClientIdx
        End Get
        Set(ByVal value As Integer)
            _ClientIdx = value
        End Set
    End Property

    Private _HierarchyIdx As Integer
    Public Property HierarchyIdx() As Integer
        Get
            Return _HierarchyIdx
        End Get
        Set(ByVal value As Integer)
            _HierarchyIdx = value
        End Set
    End Property


    Private _CostCenterIdx As Integer
    Public Property CostCenterIdx() As Integer
        Get
            Return _CostCenterIdx
        End Get
        Set(ByVal value As Integer)
            _CostCenterIdx = value
        End Set
    End Property

    Private _LocationIdx As Integer
    Public Property LocationIdx() As Integer
        Get
            Return _LocationIdx
        End Get
        Set(ByVal value As Integer)
            _LocationIdx = value
        End Set
    End Property
End Class

0 个答案:

没有答案