I have a stored procedure that returns the below sample result set. This is what I get in my code.
Resource | ResourceGroup | ResourceType
----------|-----------------|----------------
R1 | RG1 | RT1
R1 | RG2 | RT1
R2 | RG2 | RT2
R3 | RG3 | RT2
R4 | RG1 | RT2
----------|-----------------|---------------
I would like to manipulate the result set to get the below result preferably in 3 different variables.
String resource = "R1, R2, R3, R4" // Distinct values in Resource column
String resourceGroup = "RG1, RG2, RG3" // Distinct values in ResourceGroup column
String resourceType = "RT1, RT2" // Distinct values in ResourceType column
We are required to use LINQ to get this. Any help would be appreciated.
resource = string.Join(", ", setOfData.Select(z => z.Resource).Distinct());