Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:30:12+00:00 2026-06-04T04:30:12+00:00

I am trying to join two tables together using C# linq to entities. One

  • 0

I am trying to join two tables together using C# linq to entities.

One table has clients, the other table has licences. The tables are joined by Client_ID and ClientLicence_ClientID. For some reason (they are not my tables) the Client_ID is an int, and the ClientLicence_ClientID is a string.

The code I have is:

var licences = (from client in entities.Clients
                            join licence in entities.ClientLicences
                            on new { clientId = SqlFunctions.StringConvert((double)client.Client_ID) } equals
                            new { licence.ClientLicence_ClientID }
                            into clientGroup
                            where (filter.clientId == 0 || client.Client_ID == filter.clientId)
                            select licence);

When I try to compile this I get an error: The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to ‘GroupJoin’.

If I comment out the where statement then it works (albeit without filtering results).

The filter variable is a class that is passed in to the function. It only has one propery: int clientId.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:30:13+00:00Added an answer on June 4, 2026 at 4:30 am

    Look at your join:

    join licence in entities.ClientLicences on
    new { clientId = SqlFunctions.StringConvert((double)client.Client_ID) }
    equals
    new { licence.ClientLicence_ClientID }
    into clientGroup
    

    The key types are:

    • An anonymous type with a property called clientId
    • An anonymous type with a property called ClientLicence_ClientID

    Those two anonymous types can’t be compared for equality. I suspect you don’t need anonymous types at all here, actually. I’d expect this to work:

    join licence in entities.ClientLicences on
    SqlFunctions.StringConvert((double)client.Client_ID)
    equals
    licence.ClientLicence_ClientID
    into clientGroup
    

    (Obviously you don’t need all the new lines – I was just trying to separate out the various bits for clarity.)

    You claim that without the where clause it works – but that would be very surprising, given that it’s the join that’s a problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to join two tables. One being the sys.databases table and the
I am trying to perform a join on two tables. One table contains the
I am currently using Symfony2 and Doctrine2 and am trying to join two tables
I'm trying to write a LINQ expression that will join two tables and return
I am trying to join two tables in SQL, one containing a list of
I'm trying to generate a SQL query that can join two tables together and
I'm trying to join two relatively simple tables together, but my query is experiencing
I am trying to join two tables in an SQLite database using RSQLite When
I'am trying to join two tables. Lets say t1 and t2 . t1 has
I am trying to join two tables together, but have an odd requirement. Normally

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.