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 });
I'm not sure I would have figured that out on my own.
Actually, I fixed a small bug in the conversion. The original result had the assignment operator (=) instead of the comparison operator (==) in the where clause. When I reported this issue to the author, I got a prompt, polite, and appreciative response with the assurance of a fix in the next release.
One thing that I'd like to see is a snippet converter in the tool. Right now, you need to point the converter to a VS project file - something I don't normally use in file-based, ASP.NET 3.5 Web development.
For more info on VB.Net to C# Converter, see http://vbconversions.net/ .
BTW, I had to smile at C#'s use of "let" in LINQ syntax. Don't I remember Let from the earliest BASIC days?