How do I pass a parameter from the select list into a function for joining a linq query?

Posted by Ryan ONeill on Stack Overflow See other posts from Stack Overflow or by Ryan ONeill
Published on 2010-05-25T17:13:36Z Indexed on 2010/06/01 8:23 UTC
Read the original article Hit count: 243

Filed under:
|

I have a query that can be summarised in SQL as follows;

Select
    S.StockCode
From
    StockToCheck As S
Inner Join
    GetPOSStock(S.StockCode) As C
On  S.StockCode = C.StockCode;

I'm trying to do the same in Linq but it seems I cannot pass a parameter to the function I am joining on as it has not been parsed by Linq.

I imagine it would look like this (vb);

Dim x = From S In StockToCheck
    Join C In GetPOSStock(S) On S Equals C.ProductCode

Where the S var is a list of strings. This gives the error 'S' is not declared and points to the S in the function call / join (GetPOSStock). So it does not seem possible to do this in Linq, can anyone confirm?

Thanks in advance

Ryan

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about LINQ