Hi Guys,
Using ES version: 2007.0.913.0
MyGeneration version: 1.2.0.7
Oracle XE (10g free edition)
Attempting to load a single entity, but two or more are being returned from the database. I have wrapped the call to Query.Load in a Try-Catch block, but the 'An entity can only hold one record of data' exception is not being propagated up to the Load call. The call to Me.PopulateEntity(table) in OnQueryLoad, is failing with an Unhandled Exception and the RowCount check is not executed in order to throw the exception.
I did not use the 'Custom Base Class' option in generating my class, so it inherits from esEntity. The following is the code I am trying:
Code:
_543Transaction = New Transaction
_543Transaction = SetCommonWhereConditions(_543Transaction)
With _543Transaction.Query
.Where(.AccountNo.Equal(acct))
.Where(.SubAccountNo.Equal(subAcct))
.Where(.TransTypeCd.Equal("Z"))
Try
If .Load() = False Then
_543Transaction.AddNew()
_543Transaction.AccountNo = acct
_543Transaction.SubAccountNo = subAcct
_543Transaction.TransactionDate = CType("01/01/2007", Date)
_543Transaction.TransactionAmt = 5
_543Transaction.TransTypeCd = "Z"
_543Transaction.Save()
Else
_543Transaction.TransactionAmt = _543Transaction.TransactionAmt.Value + 5
_543Transaction.Save()
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End With
Code:
'The Unhandled Exception occurs on the Dim dataFound as Boolean = Me.PopulateEntity(table) line
Protected Function OnQueryLoaded(ByVal table As DataTable) As Boolean
Dim dataFound as Boolean = Me.PopulateEntity(table)
If Me.RowCount > 1 Then
throw New Exception("esTransaction can only hold one record of data")
End If
Return dataFound
End Function
What am I Missing something?