LINQ VB how to select records with maximum date (highest date)

I know how to do this in C #, but my development team doesn't use C # ...

here is the answer in C #: How to select only records with the highest date in LINQ

How to do it in VB?

Essentially, if I knew how to write lambda expressions in VB, I would install, but the materials I found do not help.

I also need to know why the identifier Into(i.e. " g") always tries to be a function every time I exit the line, which leads to this error:

http://img19.imageshack.us/i/errno.png/

+3
source share
2 answers

MSDN VB:

Dim query = From p In db.Products _
            Group p By p.CategoryID Into g = Group _
            Select CategoryID, MaxPrice = g.Max(Function(p) p.UnitPrice)

"= ", g . , .

+8
Dim q = From n In table _
        Group n By n.AccountId Into g _
        Select g.OrderByDescending(Function(t) t.Date).First() 
+7

Source: https://habr.com/ru/post/1719309/


All Articles