1
我在這裏達到了我的理解水平,但有一個簡單的請求來更改.NET數據網格中數據的排序順序。該系統似乎使用SubSonic來執行數據庫查詢,因此存在抽象層次,我只是不明白,似乎無法猜測;)。亞音速數據集排序順序
有一個在.aspx文件這樣的GridView控件下一條線:
<asp:ObjectDataSource ID="odsCsvReport" runat="server" SelectMethod="FetchAll" TypeName="WFlower.CsvReportController">
</asp:ObjectDataSource>
我搜索的項目「CsvReportController」並且在App_Code文件一個文件名爲「CsvReportController.cs」其中有這樣一類:
[DataObjectMethod(DataObjectMethodType.Select, true)]
public CsvReportCollection FetchAll()
{
CsvReportCollection coll = new CsvReportCollection();
Query qry = new Query(CsvReport.Schema);
//qry.OrderDesc("CsvReportID");
coll.LoadAndCloseReader(qry.ExecuteReader());
return coll;
}
現在,我只是不知道如何得到這個數據由「CsvReportID」字段中降序排序(目前它的上升)。
任何人都可以對此有所瞭解。就像我說的,我在這裏太深了,但它應該是一件小事,我決心要做到底!
謝謝大家!
編輯: 好了,按以下@Mike沃爾什的評論,我想這個代替:
var qry = new Select().From(CsvReport.Schema);
qry.OrderDesc(new [] {CsvReport.Columns.AssignedToID});
return qry.ExecuteAsCollection<CsvReportCollection>();
然而現在,這將引發其他地方完全不同的錯誤:
Violation of PRIMARY KEY constraint 'PK__OrdersToDelete__245EFE8C'. Cannot insert duplicate key in object 'dbo.OrdersToDelete'.
The statement has been terminated.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK__OrdersToDelete__245EFE8C'. Cannot insert duplicate key in object 'dbo.OrdersToDelete'.
The statement has been terminated.
Source Error:
Line 187: //Do database management.
Line 188: int removedUsers = SPs.Hg_DeleteInactiveUsers(14).Execute();
Line 189: int removedOrders = SPs.Hg_DeleteInactiveOrders(14).Execute();
Line 190: }
你使用什麼版本?看起來像2.3 – Aristos 2012-08-08 10:23:40
我認爲它是2.1。 – Dan 2012-08-08 10:25:33
不記得在2.1-2.2-2.3中的確切區別,但是這會爲你編譯嗎? var qry = new Select()。From(CsvReport.Schema); qry.OrderDesc(new [] {CsvReport.Columns.AssignedToID}); return qry.ExecuteAsCollection(); –
2012-08-08 23:12:59