Asp.net 不工作的命令

Asp.net 不工作的命令,asp.net,vb.net,subsonic,sql-order-by,Asp.net,Vb.net,Subsonic,Sql Order By,我使用带有gridview的objectdatasource从orm类中获取数据,但我无法正确地对其进行排序。 我正在使用下面的代码,但它并不像我在下面指定的那样按降序排列。我错过了什么?使用亚音速2.1 <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByPatID(ByVal PatientID As Object) As VisitCollection Dim col

我使用带有gridview的objectdatasource从orm类中获取数据,但我无法正确地对其进行排序。 我正在使用下面的代码,但它并不像我在下面指定的那样按降序排列。我错过了什么?使用亚音速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
公共函数FetchByPatID(ByVal PatientID作为对象)作为VisitCollection
Dim coll As VISITCOLECTION=新建VISITCOLECTION()。其中(“PatientID”,PatientID).Load()
**OrderBy.Desc(Visit.dos列)**
返回科尔
端函数

作为查询的一部分,order by将针对数据库执行。需要在调用.Load()方法之前添加它

Dim coll As VisitCollection = New VisitCollection().Where("PatientID", PatientID).OrderByDesc(Visit.Columns.DosColumn).Load()

order by作为查询的一部分对数据库执行。需要在调用.Load()方法之前添加它

Dim coll As VisitCollection = New VisitCollection().Where("PatientID", PatientID).OrderByDesc(Visit.Columns.DosColumn).Load()

拉诺莫尔是对的。在实际执行命令之前,必须指定OrderBy,因为在数据库上进行了排序

如果您使用的是亚音速2.1,我更喜欢添加的新语法,它使查询更具可读性

SubSonic.Select.AllColumnsFrom(Of Visit)().Where(Visit.PatientIDColumn).isEqualTo(PatientID).OrderByDesc(Visit.DosColumn.ColumnName).ExecuteAsCollection(Of VisitCollection)()

拉诺莫尔是对的。在实际执行命令之前,必须指定OrderBy,因为在数据库上进行了排序

如果您使用的是亚音速2.1,我更喜欢添加的新语法,它使查询更具可读性

SubSonic.Select.AllColumnsFrom(Of Visit)().Where(Visit.PatientIDColumn).isEqualTo(PatientID).OrderByDesc(Visit.DosColumn.ColumnName).ExecuteAsCollection(Of VisitCollection)()

Visit.dos列是可排序的吗?OrderBy.Desc是什么?我不是VB大师,但这是在使用LINQ
OrderBy
?如果是这样,LINQ的OrderBy实际上只在您迭代结果时才执行任何操作(它返回一个新序列而不改变原始序列)。Visit.DosColumn是否可以排序?OrderBy.Desc是什么?我不是VB大师,但这是在使用LINQ
OrderBy
?如果是这样,LINQ的OrderBy实际上只在迭代结果时执行任何操作(它返回一个新序列,而不改变原始序列)。