Hi, I'm using Adapter 2.5 & VB in a test system and all of the code shown below is in the BL.
I've fetched some data using this code :
Dim fundPlannedQtr As FundPlannedEntity
fundPlannedQtr = CType(GetFundPlannedQtr(ProjectCode, FinYear, FinQtr), FundPlannedEntity)
.. but when I try to use a field in the retrieved entity (e.g. If fundPlannedQtr.CFAmount > 0) I get:
"The entity is out of sync with its data in the database. Refetch this entity before using this in-memory instance."
As I haven't saved it and am just fetching it, I can't see what the problem is (been staring at it too long).
Anyone see where I've gone wrong?
BTW: The Function GetFundPlannedQtr looks like this:
Function GetFundPlannedQtr(ByVal ProjectCode As String, ByVal FinYear As Integer, ByVal FinQtr As Integer) As EntityBase2
Dim filter As IRelationPredicateBucket = New RelationPredicateBucket()
Dim adapter As New DataAccessAdapter
Try
Dim fundPlanned As New FundPlannedEntity
filter.PredicateExpression.Add(FundPlannedFields.ProjectCode = ProjectCode)
filter.PredicateExpression.Add(FundPlannedFields.FinancialYear = FinYear)
filter.PredicateExpression.Add(FundPlannedFields.FinancialQtr = FinQtr)
adapter.FetchEntity(fundPlanned)
Return fundPlanned
Finally
adapter.Dispose()
End Try
End Function
Thanks