开发者

How do I use "Into" LINQ expression in VB.NET?

开发者 https://www.devze.com 2022-12-27 15:14 出处:网络
I\'m converting from C# this LINQ expression. However, it does not seem to work. C# return (from w in fishSticks

I'm converting from C# this LINQ expression. However, it does not seem to work.

C#

 return (from w in fishSticks
      开发者_运维问答   group w by w.FishQty into g
         orderby g.Key descending
         select g).First().First();

VB

Return (From w In fishSticks
        Group w By w.FishQty Into g()
        Order By g.Key Descending
        Select g).First().First()

Visual Studio turns Into g into Into g() itself and then gives me this error:

Definition of method 'g' is not accessible in this context.

Any ideas?


VB.Net has different group syntax

The correct syntax is

Dim q = (From w In fishSticks
         Group By Quantity = w.FishQty Into g = Group
         Order By Quantity Descending
         Select g).First().First()
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号