Error: No overload for method 'Join' takes 4 arguments

Posts   
 
    
Bashir
User
Posts: 4
Joined: 30-Oct-2018
# Posted on: 30-Oct-2018 16:46:41   

Hi there,

I just wanted to join two tables with more than one condition in Linq. But I got the following error message: "No overload for method 'Join' takes 4 arguments".

I have searched a lot on the internet and your website, but I could not find any information.

Related Code:



LinqMetaData db = new LinqMetaData();
var result = from s in db.Survey
                  join r in db.Review on new { s.SurveyId, s.ContactId } 
                                        equals new { r.SurveyId,  r.ContactId }
                         select new { s, r };


Thanks for your time.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 30-Oct-2018 17:52:34   

Example:

var q = from c in mData.Customer
        join o in mData.Order on new { ID = c.CustomerId, Country = c.Country } equals new { ID = o.CustomerId, Country = o.ShipCountry }
        select c;

Hint: Use the same Property Names at both sides (ID & Country in my example).

Bashir
User
Posts: 4
Joined: 30-Oct-2018
# Posted on: 31-Oct-2018 10:29:59   

Walaa wrote:

Example:

var q = from c in mData.Customer
        join o in mData.Order on new { ID = c.CustomerId, Country = c.Country } equals new { ID = o.CustomerId, Country = o.ShipCountry }
        select c;

Hint: Use the same Property Names at both sides (ID & Country in my example).

Hi Walaa, Many thanks for your fast reply. I have used your hint, but still, I get the error message. To update you, we are using LLBLGen ver 4.2 right now. Do you think it is relevant to the error message?

Bashir
User
Posts: 4
Joined: 30-Oct-2018
# Posted on: 31-Oct-2018 10:48:37   

            LinqMetaData db = new LinqMetaData();
            var result = from sy in db.Survey
                         join sctemp in db.SurveyContactGroup on sy.Id equals sctemp.SurveyId into sysctemp
                         from sc in sysctemp.DefaultIfEmpty()
                         join cgtemp in db.ContactGroupRelation on sc.ContactGroupId equals cgtemp.ContactGroupId into sccgtemp
                         from cg in sccgtemp.DefaultIfEmpty()
                         join rvtemp in db.Review on new { sid = sc.SurveyId, cid = cg.ContactId } equals new { sid = rvtemp.SurveyId, cid = rvtemp.CreatedByContactId } into sccgrytemp
                         from rv in sccgrytemp.DefaultIfEmpty()
                         select rv;


Hi Walaa, This is my latest changes and now I get another error message:

"The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'GroupJoin'."

Many thanks.

Bashir
User
Posts: 4
Joined: 30-Oct-2018
# Posted on: 31-Oct-2018 11:00:58   

Hi Walaa, I have found the problem.

It was related to the type mismatch of properties! smile Sorry if I take your time.


LinqMetaData db = new LinqMetaData();
            var result = from sy in db.Survey
                         join sctemp in db.SurveyContactGroup on sy.Id equals sctemp.SurveyId into sysctemp
                         from sc in sysctemp.DefaultIfEmpty()
                         join cgtemp in db.ContactGroupRelation on sc.ContactGroupId equals cgtemp.ContactGroupId into sccgtemp
                         from cg in sccgtemp.DefaultIfEmpty()
                         join rvtemp in db.Review on new { sid = sc.SurveyId, cid = cg.ContactId } equals new { sid =[b](long)[/b] rvtemp.SurveyId, cid = rvtemp.CreatedByContactId } into sccgrytemp
                         from rv in sccgrytemp.DefaultIfEmpty()
                         select rv;


new { sid =(long) rvtemp.SurveyId, cid = rvtemp.CreatedByContactId }