2

I am trying to add a join to an existing LINQ statement but my syntax is incorrect. I looked here for examples among other places yet, my construction is still not working. Visual Studio is throwing a hissy fit. Both datasets are in the context that I am trying to work with so not sure what I am doing wrong:

The red squiggly line under the "join" keyword produces the error "The type arguments cannot be inferred from the query" The "n" and "nc" aliases produce the error "Cannot resolve symbol"

enter image description here

My Original, working statement

 var query = from nc in context.NewClubs
                           where nc.ClubMasterCustomerId == clubMasterCustId
                           select nc;
               var results = query.Any();

What I am trying to do (Illustrated in SQL)

select nc.NewClubName,nc.Id from NewClub as nc
join NewClubBuilder ncb on ncb.NewClubId = nc.Id
where ncb.BuilderClubKeyNumber = 'K00841'

My translation from SQL to LINQ (Not working)

var query = from nc in context.NewClubs
            join n in context.NewClubBuilders on n.NewClubId equals nc.Id
            where nc.ClubMasterCustomerId == clubMasterCustId
            select nc;

            var results = query.Any();

Thanks

5
  • 1
    Can you define "hissy fit"? What's the exact error reported? Commented Apr 4, 2014 at 14:24
  • Hissy fit == I included a screenshot that shows the issues in red Commented Apr 4, 2014 at 14:31
  • what error is that near the join? Commented Apr 4, 2014 at 14:35
  • Could you create a entity relationship between NewClubs and NewClubBuilders so you don't have to specify the join in the query? Commented Apr 4, 2014 at 14:40
  • The red squiggly line under the "join" keyword produces the error "The type arguments cannot be inferred from the query" Commented Apr 4, 2014 at 14:55

1 Answer 1

3

Swith the join properties, so nc.Id is first

join n in context.NewClubBuilders on nc.Id  equals n.NewClubId
Sign up to request clarification or add additional context in comments.

1 Comment

Got bitten by that one before - forgot order matters here. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.