Barre horizontale de naviagtion

lundi 18 octobre 2010

Converting VB LINQ to C# LINQ

VB.Net to C# Converter is one of the few conversion tools that knows about LINQ and lambdas and the other 3.5 stuff. I turned to a trial version of the product after going in circles on this VB code conversion:


Dim q = From c In dc.Categories, _       
p In dc.Products _
Where c.CategoryID = p.CategoryID _
+ Group p By c.CategoryName Into Group _
Select New With _
{.cgname = CategoryName, _
.prdcts = Group
}

While other tools choked, VBConversions churned out this:

var q = (from c in dc.Categories        
from p in dc.Products
where c.CategoryID == p.CategoryID
group p by c.CategoryName into g
let CategoryName = g.Key
let Group = g.ToArray()
select new { CategoryName, Group }).Select(s =>
new { cgname = s.CategoryName, prdcts = s.Group });

Aucun commentaire:

Enregistrer un commentaire