locked
No Overload Method for Join takes 4 arguments RRS feed

  • Question

  • User1536383193 posted
    this.Parts
        .Join(this.PartInformation, p => p.PartId, pi => pi.PartId, (p, pi) => new
        {
            p.ListId,
            p.PartId,
            pi.PartDescription
        });

    I am in a DbContext for my database.  I want to join the part id of one table to the part if of another table to get some information about the part.  However, when I go to put in the lambda query, I tried the linq sql version too, I get the error, "No overload method for join takes 4 arguments".  I have seen lots of examples of this type of query online.  What is wrong with the above?  

    I am using .NET 4.6.2, EF6.4, and SQL Server 2016.  It seems to act like the join is for a string because it is looking for method Join(separator).

    Thursday, September 3, 2020 10:26 PM

Answers

  • User1536383193 posted

    I found the problem.  Apparent, I made the PartId of the Parts class a string but the PartId of the PartInformation class was an integer.  Instead of telling me that the join condition had non-matching data types it gave me a cryptic error for invalid number of arguments.  Once I fixed the data types it worked fine.

    I hope this solution helps someone.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 4, 2020 3:12 PM

All replies

  • User1535942433 posted

    Hi ddelella-regal,

    Accroding to your description and codes,I have create a test and I couldn't reproduce your problems.Your problem means the function has no version with 4 parameters. Linq Join method  has 5 parameters.

    Could you tell us where do you write these codes in your project?You could check wheather exist 'this.Parts' and 'this.PartInformation'.

    https://www.tutorialsteacher.com/linq/linq-joining-operator-join

    Best regards,

    Yijing Sun

    Friday, September 4, 2020 3:04 AM
  • User1536383193 posted

    JOIN actually has only 4 arguments (parameters).  The 5th one listed is a "this" type indicating it stands for the value on the left side of the Join call.  The exact document I copied my example from is the Entity Framework homepage:

    https://entityframework.net/joining

    They even show a working example that I followed to the letter but still nothing is working.

    https://dotnetfiddle.net/yXTgHu

    Friday, September 4, 2020 1:36 PM
  • User1536383193 posted

    I found the problem.  Apparent, I made the PartId of the Parts class a string but the PartId of the PartInformation class was an integer.  Instead of telling me that the join condition had non-matching data types it gave me a cryptic error for invalid number of arguments.  Once I fixed the data types it worked fine.

    I hope this solution helps someone.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 4, 2020 3:12 PM