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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:37:06+00:00 2026-06-05T09:37:06+00:00

Am using Entity framework to connect database with my asp.net application. Here I’ve a

  • 0

Am using Entity framework to connect database with my asp.net application. Here I’ve a Foreign key table which has two columns, StaffId and SectionId. Here StaffId is the Primary key of Staff table and SectionId is the Primary key of Sections table. I have values in this table like

StaffId     SectionId
-------     ---------
  1            1
  2            5
  5            8
  1            5
  1            8

here I know the StaffId and I need to get all the SectionIds for this corresponding staffid(eg. 1,5 and 8 for staff 1 here).

If I want to know the details with First method, with the known StaffId I can do like,

DataObject.Entities dataEntities=new DataObject.Entities();

DataObject.Section section = dataEntities.Sections.First(s=>s.Staffs
                                  .Select(ss=>ss.StaffId).Contains(staffId));

with this I can get the information about the first section that matches with the StaffId.(ex:info about sectionid=1 here)

In the same way I tried to get all the sectionIds for a particular staffId like,

List<int> sectionIds = dataEntities.Sections.Where(s => s.Staffs.Where
                       (ss => ss.StaffId == staffId)).Select(sec=>sec.SectionId);

but its not working, can anyone help me here

  • 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-05T09:37:09+00:00Added an answer on June 5, 2026 at 9:37 am

    here I know the StaffId and I need to get all the SectionIds for this
    corresponding staffid

    List<int> sectionIds = dataEntities.Sections
        .Where(se => se.Staffs.Any(st => st.StaffId == staffId))
        .Select(se => se.SectionId)
        .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp.net application and am using Entity Framework to connect it with the
I'm using entity framework to connect the database. I've a table(Let's call it File)
Using Entity Framework, I suddenly get this strange error after publishing my asp.net mvc
I'm using entity framework to connect with the database. I've one little problem: I've
I'm using C#, .NET (4.0) and Entity Framework to connect to SQL CE 4.0.
I'm dealing with a .NET windows form application written in C#, using entity framework
I am using ADO.NET Entity framework for connect db and get data. I want
I created a WPF C# application and using entity framework to connect to an
I am trying to create a web app using ASP.Net MVC3, Entity Framework and
I have the following problem. I am using Entity Framework to connect to a

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.