Paging Cache

Paging Cache

Old forum URL: forums.lhotka.net/forums/t/1564.aspx


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?

ajj3085 replied on Monday, October 23, 2006

If you're not going through the dataportal, then you're probably hurting your chances to move to a physical 3 tier environment later.

Probably what you need to do is create an instance method on your collection.  This method would call the dataportal, giving the criteria for the loads which should be loaded.  The results you get back can then be added to the existing collection.

HTH
Andy

Copyright (c) Marimer LLC