I have the following result set that was generated as the result of a Linq query. I would like to convert this to a hierarchical result set. The first two columns would represent the 'master' row, columns 3 and 4 would represent a child list of the master row, and column 5 and 6 would represent a second child list of the master row. The columns containing the value 1971 are the joining columns.
The end result should be a master object with a list of containers (G2 columns) and a list of printers (G3 columns).
What would the query look like to convert this to hierarchical form?
G1_ID G1_CellName G2_ContainerID G2_ID G2_SerialNumber G3_ID G3_PrinterName
1971 Default Cell 1935 1971 1101929 1971 PBG-PrtEmulator1
1971 Default Cell 1936 1971 1101930 1971 PBG-PrtEmulator1
1971 Default Cell 2189 1971 1102183 1971 PBG-PrtEmulator1
groupby?
var result = from eachData in data
group eachData by new{ eachData .G1_ID, eachData .G1_CellName }
into g1
from eachG1 in g1
group eachG1 by new { eachG1.G2_..., eachG1.G2_... }
into g2
for eachG2 in g2
group eachG2 by new { eachG2.G3_... }
into g3
select g3;
haven't test it. but i'm sure its gonna look just like this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With