I have a page that I created that has the following configuration:
poDataSrc = New LLBLGenProDataSource()
With poDataSrc
.ID = pc_sDataSrcId
.LivePersistence = True
.CacheLocation = DataSourceCacheLocation.Session
.DataContainerType = DataSourceDataContainerType.EntityCollection
.EntityCollection = Me.GetDataFromBuffer()
.EnablePaging = True
.SortingMode = DataSourceSortingMode.ServerSide
End With
Later on, in the Load event, I do the following:
' This gets the correct "RelationsCollection" for this Form.
Dim relationsToUse As New RelationCollection
relationsToUse = DataObjectLoader.GetEntityRelations(Me.CurrentFormName)
With poDataSrc
Dim oFilter As New PredicateExpression
Dim oCustomFilter As PredicateExpression = _
Me.GMod_BuildCustomWhereClause()
Dim oContextFilter As PredicateExpression = _
Me.GMod_BuildContextWhereClause()
With oFilter
' Add the GridWhereClause if it exists..
If oWhere IsNot Nothing Then
logger.Info("Set GMod Predicate = '{0}'", oWhere.WhereClause)
.Add(oWhere)
End If
' Add any custom filter, if it exists...
If (oCustomFilter IsNot Nothing) Then
.Add(oCustomFilter)
End If
' Add any Context filter, if it exists
If (oContextFilter IsNot Nothing) AndAlso (oContextFilter.Count > 0) Then
.Add(oContextFilter)
End If
End With
If oFilter.Count > 0 Then
logger.Trace("[{0}] > oFilter = '{1}'", Me.FormName, Divix.Data2.LgpUtil.GetPredicateQueryText(oFilter))
.FilterToUse = oFilter
Else
.FilterToUse = Nothing
End If
' Add Relations
.RelationsToUse = relationsToUse
' This is put here for testing to see what happens when the "SorterToUse" is changed in a PostBack.
If Not Me.IsPostBack Then
Dim oSorter As New SortExpression
With oSorter
.Add(New SortClause(HelperClasses.AccountFields.QbcompanyName, SortOperator.Ascending))
End With
.SorterToUse = oSorter
Else
Dim oSorter As New SortExpression
With oSorter
.Add(New SortClause(HelperClasses.LocationFields.Description, SortOperator.Ascending))
End With
.SorterToUse = oSorter
End If
.Refetch = True
'
End With
Now here is where things are odd.
Aside from sorting everything works flawlessly on first page load.
On First Page Load it sets the sort of the "Grid" that is bound to this DataSource correctly, all is well.
On 2nd page load, sorting is not functioning as I expect (I expected it to SORT by LOCATION.Description...according to the Tracing output it creates a SELECT with NO "ORDER BY" clause at all.
So my question is this:
How can I change the "sort" of DataSource and have that get reflected in the DataSource that is fetched?
Is there some special voodoo going on that doesn't cause the "ORDER BY" to be persisted because I have "LivePersistance=True"?
I realize that changing the "Sort" will force it to re-fetch the dataset, which is fine, but it should still function (IMHO).
I'm fairly certain I could probably make it ALL work if I turned LivePersistance=False but I really don't want to have to do that (I may have to at some point, but I almost have this all working and setting that to "False" will require me to re-do all the binding logic that is currently working quite well...)
Thanks.
Andrew.
EDIT:
Designer Ver: 2.0.0.0 Final
ORMSupportClasses Ver: 2.0.07.0105
Type: SelfServicing
DB: SQL2000
Framework Ver: ASP.NET 2.0