daleedom posted on Monday, October 23, 2006
I have been working on a paging routine.
I have a ReadOnlyListBase class defined. I then load only 200 rows into the collection. The idea is to then add more rows to the ReadOnlyListBase Class when the DataGridView needs the data via CellValueNeeded.
What I have done is create a function in the ReadOnlyListBase class that gets one ReadOnlyBase class. Whenever I call this function (shown Below) I check the collection count against the RowIndex the data grid wants. If I don't have enough rows I go Fetch more.
Public Function GetCase(ByVal RowIndex As Long) As ServiceCaseInfo
While RowIndex + 1 > Me.count
'*** When I Call DataPortal.Fetch it creates/returns a new object ***
'DataPortal.Fetch(Of ServiceCaseList)(oCriteria)
Fetch(oCriteria.StatusCode, oCriteria.SearchText, oCriteria.DateColumnName, oCriteria.StartDate, oCriteria.EndDate)
End While
Return Me.Item(RowIndex)
End Function
The problem is that CSLA appears
to create a new version of the Class so when it gets to the DataPortal.Fetch routine
the Collection empty. My work around is to call the actual Fetch routine directly. It works, but I am afraid that I am breaking the framework when I do this.
I am really new to CSLA, but from what I've read this behavior is an important feature. So what is the correct solution? What are your thoughts?