I have a linq query which works fine in C# and now I need it in VB.net, I am finding it hard to convert it myself. I will be much appreciated if someone can lend me a hand. Thanks a lot.
var replacement = new XDocument(
new XElement("root",
original.Descendants("Song")
.GroupBy(x => (string) x.Attribute("artist"))
.Select((songsForArtist, index) => new XElement("artist",
new XAttribute("id", index + 1),
new XAttribute("name", songsForArtist.Key),
songsForArtist))));
Dim replacement = New XDocument(New XElement("root", original.Descendants("Song").GroupBy(Function(x) Convert.ToString(x.Attribute("artist"))).[Select](Function(songsForArtist, index) New XElement("artist", New XAttribute("id", index + 1), New XAttribute("name", songsForArtist.Key), songsForArtist))))
thutaaung
Member
14 Points
29 Posts
How to convert Linq C# to Vb.net
Apr 30, 2012 08:21 AM|LINK
Hi ...
I have a linq query which works fine in C# and now I need it in VB.net, I am finding it hard to convert it myself. I will be much appreciated if someone can lend me a hand. Thanks a lot.
var replacement = new XDocument( new XElement("root", original.Descendants("Song") .GroupBy(x => (string) x.Attribute("artist")) .Select((songsForArtist, index) => new XElement("artist", new XAttribute("id", index + 1), new XAttribute("name", songsForArtist.Key), songsForArtist))));Linq csharp
karthicks
All-Star
31330 Points
5412 Posts
Re: How to convert Linq C# to Vb.net
Apr 30, 2012 09:11 AM|LINK
hi, Converted Code
Dim replacement = New XDocument(New XElement("root", original.Descendants("Song").GroupBy(Function(x) Convert.ToString(x.Attribute("artist"))).[Select](Function(songsForArtist, index) New XElement("artist", New XAttribute("id", index + 1), New XAttribute("name", songsForArtist.Key), songsForArtist))))Karthick S
thutaaung
Member
14 Points
29 Posts
Re: How to convert Linq C# to Vb.net
Apr 30, 2012 09:28 AM|LINK
Hi Kar,
I knew developerfusion but I didn't think they can convert Linq so I didn't try .. A new lesson learnt. Thanks a lot.