(From d In InputFile.AsEnumerable()
Group d By k1 = d(6).ToString().Trim(), k2 = d(8).ToString().Trim() Into grp = Group
Let s12 = String.Join(“,”, grp.Select(Function(x) x(12).ToString()))
Let s13 = String.Join(“,”, grp.Select(Function(x) x(13).ToString()))
Let s = s12 + “,” + s13
Let ra = New Object() {k1, k2, s}
Select joiningDT.Rows.Add(ra)).CopyToDataTable()
It is working but it is joining blank rows as well. How to tackle it.
(From d In InputFile.AsEnumerable()
Group d By k1 = d(6).ToString().Trim(), k2 = d(8).ToString().Trim() Into grp = Group
Let s12 = If(String.Join(",", grp.Select(Function(x) x(12).ToString())).Replace(",","").Trim.Equals(String.Empty),"",String.Join(",", grp.Select(Function(x) x(12).ToString())))
Let s13 = If(String.Join(",", grp.Select(Function(x) x(13).ToString())).Replace(",","").Trim.Equals(String.Empty),"",String.Join(",", grp.Select(Function(x) x(13).ToString())))
Let s = s12 + "," + s13
Let ra = New Object() {k1, k2, s}
Select joiningDT.Rows.Add(ra)).CopyToDataTable()
(From d In InputFile.AsEnumerable()
Group d By k1 = d(6).ToString().Trim(), k2 = d(8).ToString().Trim() Into grp = Group
Let e12 = grp.Select(Function(x) x(12).ToString().Trim)
Let e13 = grp.Select(Function(x) x(13).ToString().Trim)
Let ec = e12.Concat(e13).Where(Function (x) Not String.IsNullOrEmpty(x))
Let s = String.Join("," , ec)
Let ra = New Object() {k1, k2, s}
Select joiningDT.Rows.Add(ra)).CopyToDataTable()
Sorry @ppr and @Anil_G , i posted the wrong query. Attaching y query below:
(From d In InputFile.AsEnumerable()
Where d(12).ToString isNot Nothing and d(13).ToString isNot Nothing
Group d By k1 = d(6).ToString().Trim(), k2 = d(8).ToString().Trim()
Into grp = Group
Let s13 = String.Join(“,”, grp.Select(Function(x) x(13).ToString()))
Let s12 = String.Join(“,”, grp.Select(Function(x) x(12).ToString()))
Let ra = New Object() {k1, k2, s12, s13}
Select joiningDT.Rows.Add(ra)).CopyToDataTable()
(From d In InputFile.AsEnumerable()
Where d(12).ToString isNot Nothing and d(13).ToString isNot Nothing
Group d By k1 = d(6).ToString().Trim(), k2 = d(8).ToString().Trim()
Into grp = Group
Let s12 = If(String.Join(",", grp.Select(Function(x) x(12).ToString())).Replace(",","").Trim.Equals(String.Empty),"",String.Join(",", grp.Select(Function(x) x(12).ToString())))
Let s13 = If(String.Join(",", grp.Select(Function(x) x(13).ToString())).Replace(",","").Trim.Equals(String.Empty),"",String.Join(",", grp.Select(Function(x) x(13).ToString())))
Let ra = New Object() {k1, k2, S12,S13}
Select joiningDT.Rows.Add(ra)).CopyToDataTable()
(From d In InputFile.AsEnumerable()
Where d(12).ToString isNot Nothing and d(13).ToString isNot Nothing
Group d By k1 = d(6).ToString().Trim(), k2 = d(8).ToString().Trim()
Into grp = Group
Let s12 = String.Join(",", grp.Where(function(x) Not String.IsNullOrEmpty(x(12).ToString().Trim)).Select(Function(x) x(12).ToString()))
Let s13 = String.Join(",", grp.Where(function(x) Not String.IsNullOrEmpty(x(13).ToString().Trim)).Select(Function(x) x(13).ToString()))
Let ra = New Object() {k1, k2, S12,S13}
Select joiningDT.Rows.Add(ra)).CopyToDataTable()
(From d In InputFile.AsEnumerable()
Group d By k1 = d(6).ToString().Trim(), k2 = d(8).ToString().Trim() Into grp = Group
Let s12 = String.Join(“,”, grp.Where(Function(x) Not String.IsNullOrWhiteSpace(x(12).ToString())).Select(Function(x) x(12).ToString()))
Let s13 = String.Join(“,”, grp.Where(Function(x) Not String.IsNullOrWhiteSpace(x(13).ToString())).Select(Function(x) x(13).ToString()))
Let s = s12 + “,” + s13
Let ra = New Object() {k1, k2, s}
Select joiningDT.Rows.Add(ra)).CopyToDataTable()