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 6979485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:53:35+00:00 2026-05-27T17:53:35+00:00

I have 1:n relationship between to tables in a database: Employee (1) : Role

  • 0

I have 1:n relationship between to tables in a database: Employee (1) : Role (n)
Role has foreignKey named idEmployee

I want to create a linq statement which will get every role for a given customer. I want to make something like this:

var myQuery = from r in Role 
              where r.idEmployee == someId
              select r;

But, r doesn’t have an idEmployee property! How can I get the value of the foreign key?

  • 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-05-27T17:53:36+00:00Added an answer on May 27, 2026 at 5:53 pm

    If you are using EF4.0 at least, this will give you what you need: Foreign keys in Entity Framework

    If you’re using EF1.0, your problem is more serious since it does not show foreign keys in model. You need to iterate through EntityKey.EntityKeyValues collection in search of valid value. But I think this would only get you value of foreign key and would not work in query (since EF would not know how to translate it to SQL query).

    But since you have foreign keys, why don’t you simply use NavigationProperty to navigate to Employee entity and check value there?

    var myQuery = from r in Role 
                  where r.Employee.idEmployee == someId
                  select r;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that I'm trying to create a relationship between so I
I have a project that necessarily spans several databases. One database has tables: CREATE
I have a domain object which represents a 1:n relationship between database tables. public
I have an identifying relationship between two tables in the database. The parent table
I have a 1:1 relationship between two tables. I want to find all the
In a database, one may create a many-to-many relationship between tables by creating a
I have a many-to-many relationship between two tables, let's say Friends and Foods. If
I have 3 tables, team(id,name) player(id,teamid,name) playerdetail(id,playerid,height,weight), the relationship between team and player is
I have two tables, blogs and posts, with the expected relationship between them. Posts
In my model, I have two tables with a 1:0..1 relationship between them: (Example

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.