0
votes

Using WPF and EF and new to both. I may use the wrong terminology.

Using the EF wizard and code generators, I set up an EF using several tables, one of which is a lookup table.

I set up a form with a datagrid for the user to edit items in this lookup table. An issue I'm having is that the user can edit a cell, then close the form, but the editing of the cell will not update the underlying SQL database. I researched INotifyPropertyChanged and it seemed to be what I needed.

I implemented INotifyPropertyChanged to class bound to the datagrid. Before the implementation, the datagrid displayed all null values. After implementation, a message displays when the first null value is read that a nullable object must have a value.

Code:

    Public Property ProcedureName As String
    Get
        Return _ProcedureName
    End Get
    Set(value As String)
        _ProcedureName = value
        RaisePropertyChanged("ProcedureName")
    End Set
End Property
Private _ProcedureName As String

The exception occurs at "_ProcedureName = value".

Entire class:

Imports System

Imports System.Collections.ObjectModel

Partial Public Class tlkpProcedures_PartB Inherits PropertyChangedBase Public Property CPT As String Get Return _CPT End Get Set(value As String) _CPT = value RaisePropertyChanged("CPT") End Set End Property Private _CPT As String Public Property ProcedureName As String Get Return _ProcedureName End Get Set(value As String) _ProcedureName = value RaisePropertyChanged("ProcedureName") End Set End Property Private _ProcedureName As String

Public Property BillingAmount As Nullable(Of Decimal)
    Get
        Return _BillingAmount
    End Get
    Set(value As Nullable(Of Decimal))
        _BillingAmount = value
        RaisePropertyChanged("BillingAmount")
    End Set
End Property
Private _BillingAmount As Decimal
Public Property UniqueID As Integer

Public Overridable Property tblBilling_PartB As ObservableCollection(Of tblBilling_PartB) = New ObservableCollection(Of tblBilling_PartB)

End Class

Any help or advice is appreciated.

1
Do you really think that anybody could work out what your problem is from that very basic description in just four lines? That's like going to a motor garage and saying 'My car won't start. It's red and has four wheels and windows. What's wrong with it?'Sheridan
Ok, my apologies. I've added more to my original post. Let me know if there's something else I need to post.user3014908
Dude... you should always read over your question before you post it... half of your class formatting is messed up. On this website, you have to add four spaces to the start of each line to tell the formatter to format that line as code. So add four spaces to the start of each line in your class and it should be ok. Where is the code that you use to update the EF tables?Sheridan

1 Answers

0
votes

I'm not very good at VB but it seems like you try to assign a Nullable ( value As Nullable(Of Decimal) ) to a non-nullable (Private _BillingAmount As Decimal).

You should either cast value as Decimal or define _BillingAmount as Nullable(Of Decimal).