The type of the arguments cannot be inferred usage Linq GroupJoin

I'm trying to make a linq GroupJoin, and I receive the fore mentioned error. This is the code

public Dictionary<string, List<QuoteOrderline>> GetOrderlines(List<string> quoteNrs)
{
    var quoteHeadersIds = portalDb.nquote_orderheaders
        .Where(f => quoteNrs.Contains(f.QuoteOrderNumber))
        .Select(f => f.ID).ToList();

    List<nquote_orderlines> orderlines = portalDb.nquote_orderlines
        .Where(f => quoteHeadersIds.Contains(f.QuoteHeaderID))
        .ToList();

    var toRet = quoteNrs
        .GroupJoin(orderlines, q => q, o => o.QuoteHeaderID, (q => o) => new 
        {
            quoteId = q,
            orderlines = o.Select(g => new  QuoteOrderline()
            {
                Description = g.Description,
                ExtPrice = g.UnitPrice * g.Qty,
                IsInOrder = g.IsInOrder,
                PartNumber = g.PartNo,
                Price = g.UnitPrice,
                ProgramId = g.ProgramId,
                Quantity = (int)g.Qty,
                SKU = g.SKU
            }).ToList()
         });           
 }
Jon Skeet
people
quotationmark

I suspect this is the immediate problem:

(q => o) => new { ... }

I suspect you meant:

(q, o) => new { ... }

In other words, "here's a function taking a query and an order, and returning an anonymous type". The first syntax simply doesn't make sense - even thinking about higher ordered functions, you'd normally have q => o => ... rather than (q => o) => ....

Now that won't be enough on its own... because GroupJoin doesn't return a dictionary. (Indeed, you don't even have a return statement yet.) You'll need a ToDictionary call after that. Alternatively, it may well be more appropriate to return an ILookup<string, QuoteOrderLine> via ToLookup.

people

See more on this question at Stackoverflow