This is a migrated thread and some comments may be shown as answers.

Converter crashing

4 Answers 72 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
CD
Top achievements
Rank 1
CD asked on 30 Aug 2011, 02:17 AM
Converter is crashing when trying to convert Telerik code from MVC Grid Demo, SessionProductRepository object


public static IList<EditableProduct> All()
       
{
           
IList<EditableProduct> result =
               
(IList<EditableProduct>)HttpContext.Current.Session["Products"];
           
if (result == null)
           
{
               
HttpContext.Current.Session["Products"] = result =
                   
(from product in new NorthwindDataContext().Products
                     
select new EditableProduct
                     
{
                         
ProductID = product.ProductID,
                         
ProductName = product.ProductName,
                         
UnitPrice = product.UnitPrice.HasValue ? product.UnitPrice.Value : default(decimal),
                         
UnitsInStock = product.UnitsInStock.HasValue ? product.UnitsInStock.Value : default(int),
                         
Discontinued = product.Discontinued,
                         
LastSupply = DateTime.Today
                     
}).ToList();
           
}
           
return result;
       
}

4 Answers, 1 is accepted

Sort by
0
Todd
Telerik team
answered on 31 Aug 2011, 04:05 AM
Hi Cd,

Thanks for reporting the issue. Unfortunately, the current version of NRefactory that powers the Telerik Converter has some trouble with the LINQ expression syntax. We will research the availability of updates to the open source NRefactory that make be able to address this. In the mean time, the Converter will not be able to convert this specific syntax.

In the meantime, you might try this other online converter which seems to have some support for LINQ syntax conversion:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

I hope that helps!

-Todd
0
Sebastian
Top achievements
Rank 2
answered on 15 Sep 2011, 04:34 PM
Hello,

Is there a work around this one?

Thank you,
S
0
Darren
Top achievements
Rank 1
answered on 20 Sep 2011, 05:19 PM
I have same issue. But fortunately, Linq syntax in C# and in VB are the same. So you just need to remove the Linq statement and convert, then put the Linq statement back.
0
Todd Anglin
Top achievements
Rank 2
answered on 20 Oct 2011, 09:43 PM
Thanks for sharing the workaround, Darren. Hopefully this helps others.

I don't think all LINQ syntax is 100% mappable from VB to C#, but hopefully this help get more of your code easily converted.

-Todd
Tags
Ajax
Asked by
CD
Top achievements
Rank 1
Answers by
Todd
Telerik team
Sebastian
Top achievements
Rank 2
Darren
Top achievements
Rank 1
Todd Anglin
Top achievements
Rank 2
Share this question
or