Order without working
I am using objectdatasource with gridview to get data from my orm class, but I cannot get it to order properly. I am using the code below, but it does not appear in descending order as I said below. What am I missing? Using subsonic 2.1
<DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByPatID(ByVal PatientID As Object) As VisitCollection
Dim coll As VisitCollection = New VisitCollection().Where("PatientID", PatientID).Load()
**OrderBy.Desc(Visit.DosColumn)**
Return coll
End Function
+1
source to share
2 answers
Ranomor is right. You must specify OrderBy before executing the command when the order is executed in the database.
If you are using SubSonic 2.1, I prefer the new syntax that has been added, which makes the query much more readable
SubSonic.Select.AllColumnsFrom(Of Visit)().Where(Visit.PatientIDColumn).isEqualTo(PatientID).OrderByDesc(Visit.DosColumn.ColumnName).ExecuteAsCollection(Of VisitCollection)()
+2
source to share