Compiler error on Linq INTO keyword in vb.net

Posts   
 
    
kirwitt
User
Posts: 1
Joined: 01-Feb-2010
# Posted on: 01-Feb-2010 11:48:08   

Hello,

I'm just testing LLBLGen Pro 2.6 using the trial version.

This works fine (Northwind database on SQL2005 Developer):

Dim q = From emp In .Employees _
Join ord In .Orders On ord.EmployeeId Equals emp.EmployeeId _
Select New With {emp.EmployeeId, emp.FirstName, ord.CustomerId}

This doesn't work:

Dim Q = From C In .Customers _
Join o In .Orders On C.CustomerId Equals o.CustomerId Into oc _
Where C.Country = "France" _
From x In oc.DefaultIfEmpty _
Where x.OrderId = Nothing _
Select C

VB.NET 2008 SP1 reports a compile-time error on the "Into" keyword: End of statement expected. What am I doing wrong?

Kind regards.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Feb-2010 18:20:05   

AFAIK, "Into" is used for Grouping

Group ...... Into.....
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 02-Feb-2010 09:36:27   

You're using the C# syntax to create a group join:

from c in metaData.Customer join o in metaData.Order on c.CustomerId equals o.CustomerId into oc

'oc' is then a group-joined set.

VB.NET has a special keyword to create a group join. So instead of 'Join', specify 'Group Join'. See also the 'Join' keyword in the MSDN for an example. It would have given you the answer right away wink

Frans Bouma | Lead developer LLBLGen Pro