1

我正在查询数据库以获取表格数据

ID   NAME
1     ABC
2     XYZ
3     IJK
4     LMN
5     OPQ
6     RSS
7     NTN
8     UPS
9     DHL
10    XXX   

I want this to convert it into following format to display in Grid

1  ABC    2 XYZ     3 IJK
4  LMN    5 OPQ     6 RSS
7  NTN    8 UPS     9 DHL
10 XXX


I want to Convert it into a List of Following Object

Class NewData
{
  Int Id1
  string Name1
  int id2
  string Name2
  int id3
  string Name3

}

4

1 回答 1

0

或者你可以用类似的东西查询它

Select C1.ID,C1.Name, C2.ID,C2.Name, C3.ID,C3.Name 
From MyTAble c1
Left Join MyTable c2 On c2.ID = (C1.ID + 1)
Left Join MyTable c3 On c3.ID = (C1.ID + 2)
Where ((C1.ID -1) % 3) = 0;

注意,这是因为您的 ID 是连续的。如果他们不是,就会留下空白。

于 2013-02-04T23:35:24.253 回答