tags:

views:

70

answers:

2

Hi,

Can any one help me to change the below code to VB .Net.

   var(query = From row In dtInvoice.AsEnumerable())
            group  row by   new  { InvNo =  row.Field< string >( "InvNo" ),
            EmpUNID = row.Field< decimal >( "EmployeeUNID" )} into  grp                        
            OrderBy(grp.Key.InvNo)
                select new
                {                           
                    Key =  grp.Key,  
                    InvNo = grp.Key.InvNo,
                    EmpID = grp.Key.EmpUNID,                                                           
                    TotalCost = grp.Sum(r => r.Field< decimal >( "TotalCost" )),
                    TotalRev = grp.Sum(r => r.Field< decimal >( "TotalRev" ))
                }

Thanks and regards, Vaduganathan.C

A: 

That's not hard.

Insert your code in this link below and it's instantly converted.

developerfusion.com/converter

NicoJuicy
+2  A: 

The InstantVB tool produces this output:

'INSTANT VB NOTE: This code snippet uses implicit typing. You will need to set 'Option Infer On' in the VB file or set 'Option Infer' at the project level:'

Dim query = From row In dtInvoice.AsEnumerable()) group row by New With {Key .InvNo =     row.Field(Of String )("InvNo"), Key .EmpUNID = row.Field(Of Decimal)("EmployeeUNID")} into     grp OrderBy(grp.Key.InvNo) select New
        grp.Sum(Function(r) r.Field(Of Decimal     )("TotalCost")), TotalRev = grp.Sum(Function(r) r.Field(Of Decimal)("TotalRev"))
        grp.Key.EmpUNID, TotalCost = grp.Sum(Function(r)     r.Field(Of Decimal)("TotalCost")), TotalRev
        grp.Key.InvNo, EmpID = grp.Key.EmpUNID, TotalCost
        grp.Key, InvNo = grp.Key.InvNo, EmpID
        Key = grp.Key, InvNo
amartynov