将其转换为VB .Net?

时间:2009-11-18 15:39:22

标签: vb.net linq

任何人都可以帮我将以下代码更改为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" ))
                }

2 个答案:

答案 0 :(得分:2)

InstantVB工具生成此输出:

'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

答案 1 :(得分:1)

将您的代码插入此developerfusion.com/converter的网络应用中,并立即转换。