C# 将表格列表数据转换为C中的Rowa#
我正在查询数据库以获取表格数据C# 将表格列表数据转换为C中的Rowa#,c#,C#,我正在查询数据库以获取表格数据 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
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
}或者您可以通过以下方式查询出来
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是连续的。如果不是这样,就会留下缺口。酷。那么到目前为止你尝试了什么?这很有帮助,但我需要在c#中进行转换,所以请发布你尝试过的内容。有很多方法可以做到这一点,我发现很难接受你甚至不能想出一个。