2

我在使用 C# 中的 ClearQuest Api 按字段对结果集进行排序时遇到问题。我试图按照本教程进行操作,但 C# ClearQuest Api 中的方法似乎不一样。如果有人可以发布一个如何按字段名称升序对数据集进行排序的示例,那就太好了!

编辑:这是我尝试过的代码示例:

Session cqSession = new Session();

cqSession.UserLogon("exampleuser", "examplepassword", "exampledb", 2, "ex_db_set");

OAdQuerydef queryDef = (cqSession.BuildQuery("Defect")) as OAdQuerydef;


// build fields of result set
queryDef.BuildField("id");
queryDef.BuildField("state");
queryDef.BuildField("headline");
queryDef.BuildField("total_est_hrs");

// Create filter operators
IOAdQueryFilterNode filter1 = queryDef.BuildFilterOperator(AND);
IOAdQueryFilterNode filter2 = filter1.BuildFilterOperator(AND);
IOAdQueryFilterNode filter3 = filter2.BuildFilterOperator(AND);

// build filters
filter1.BuildFilter("state", EQUAL, "Opened");
filter2.BuildFilter("id", GREATER_THAN, "SCR00032251");
filter2.BuildFilter("id", LESS_THAN, "SCR00139300");
filter3.BuildFilter("total_est_hrs", GREATER_THAN, "0");

// Here is where I am having a tough time sorting the id field.
// I just want the id field to be sorted in order ascending from least to greatest
IOAdQueryFieldDef queryFieldDef = queryDef.QueryFieldDefs("id");
queryFieldDef.SetSortType(AD_SORT_ASC);

OAdResultset rs = (cqSession.BuildResultSet(queryDef)) as OAdResultset;

rs.ExecuteAndCountRecords();
4

0 回答 0