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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:33:03+00:00 2026-06-07T13:33:03+00:00

I have 2 tables. 1 has entity’s, 1 per row. Another is simply a

  • 0

I have 2 tables. 1 has entity’s, 1 per row. Another is simply a mapping table of my EntitiesID and EmployeeID. I am trying to write a LINQ method that returns all Entities from the First Table where the EntityID is in the mapping table that is filtered by the EmployeeID.

Simplified Table Structure Example
TaskTable: ID, Description, Status
TaskViewTable: ID, TaskID, EmployeeID

So I want to return all Rows from TaskTable where the ID is in a SubQuery results of TaskViewTable based on EmployeeID.

Any help on doing this in LINQ? I have a 1 to Many set up between the two tables as well. I know there are similar questions am maybe I’m dense but they didn’t seem to apply completely to what I was asking.(e.g. Linq Return Filtered Children)

Sorry forgot to show what I have so far:

IQueryable<tblTask> tTask=context.GetTable<tblTask>();
return tTask.Where(t => t.tblTasksViews.Where(v => v.EmployeeID == empID))

It, however, does not like my wherewith an unkown method Where(?)

  • 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-07T13:33:04+00:00Added an answer on June 7, 2026 at 1:33 pm

    Something like this should do the trick:

    var tasks = tTask.Where(t => 
        tTaskView.Where(v => v.ID == empId).Select(v => v.TaskId).Contains(t.ID));
    

    You could break up the above into two sections:

    //1.) Get all task views for the employeeID and only select the mapped TaskId
    var taskViews = tTaskView.Where(v => v.ID == empId).Select(v => v.TaskId); //taskViews = IEnumerable<int>
    
    //2.) Then get all tasks from the filtered task ids  
    var tasks = tTask.Where(t => taskViews.Contains(t.ID));
    

    UPDATE

    //3.) Project filtered results into IEnumerable<Task>
    return tasks.Select(t => new Task() 
    { 
        ID = t.ID, 
        ActionableID = t.ActionableID, 
        StatusID = t.StatusID, 
        TypeID = t.TypeID, 
        Description = t.Description 
    });
    

    You can, of course, string everything into a nice one-liner:

    public List<Task> GetTasks(int empId) 
    {
        return tTask
            .Where(t => tTaskView.Where(v => v.ID == empId).Select(v => v.TaskId).Contains(t.ID))
            .Select(t => new Task() 
            { 
                ID = t.ID, 
                ActionableID = t.ActionableID, 
                StatusID = t.StatusID, 
                TypeID = t.TypeID, 
                Description = t.Description 
            }).ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following situation: An Conversations entity/table which has multiple Tags associated to
I have two entities // All details has been removed @Entity @Table(name = "A_TABLE_NAME")
i have 5 tables,in every table it has 4 rows. so i need to
I have a few tables that reference the same table. For example: Person has
I Have two tables: Users and News. Table News has columns id, name, createdby,
I have an entity model which has some tables added from my DB. I
I have a SampleDB that contains 3 tables. Table Employees (EmployeeID, EmployeeName) Table Projects
I have three tables: User, Employee and Worker. User table has one-to-zero-or-one relationship with
I have two tables: object that has object_id column and avalues that have object_id
I have SQL Server 2008 R2 and one of my tables has a date

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.