2011-07-26 7 views
1

아래 코드를 vb.net으로 변환하려면 어떻게해야합니까?C# Linq를 Vb.net으로 변환하는 방법

나는 C#의 익명 클래스의 select new { c.CustomerID, OrderCount = c.Orders.Count() };

public void Linq76() 
{ 
    List<Customer> customers = GetCustomerList(); 

    var orderCounts = 
     from c in customers 
     select new { c.CustomerID, OrderCount = c.Orders.Count() }; 

    ObjectDumper.Write(orderCounts); 
} 

답변

3

을 변환 할 수 없습니다. VB도 그렇게 지원합니다. 예 : this을 참조하십시오.

VB에서 LINQ를 사용하는 방법에 대한 기본 정보는 다음을 참조하십시오. resource.

4

this tool.

Public Sub Linq76() 
    Dim customers As List(Of Customer) = GetCustomerList() 

    Dim orderCounts = From c In customers New With { _ 
     c.CustomerID, _ 
     Key .OrderCount = c.Orders.Count() _ 
    } 

    ObjectDumper.Write(orderCounts) 
End Sub 

MSDN:Anonymous Types (Visual Basic)

관련 문제