I have a code below in an Entity Class. It throws exception in the Entity.Designer.vb saying the value Amount in Table Patient is DbNull.
If _patientDetails.ID > 0 Then
If _patientDetails.Amount = EntityEnums.Patient.Existing
Then
_patientDetails.SetAmountNull()
End If
Catch ex As Exception
_patientDetails.SetAmountNull()
End Try
End If
It goes to the "Return" line as below and throws exception.
Public Property Amount() As Integer
Get
Try
Return CType(Me(Me.tablePatient.AmountIDColumn),Integer)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'AmountIDColumn' in table 'Patient' is D"& _
"BNull.", e)
End Try
End Get
Set
Me(Me.tablePatient.AmountIDColumn) = value
End Set
End Property
Exception Details are
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from type 'DBNull' to type 'Integer' is not valid.