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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:02:35+00:00 2026-05-13T08:02:35+00:00

I’m have an issue with this entity query that I am hoping to get

  • 0

I’m have an issue with this entity query that I am hoping to get some help with.

Overall what I am trying to do is query for entries in the GoalNotes table as well as include the Employee reference for each note. The GoalNotes table has a foreign key relating it to the Employee table.

I am then trying to query the GoalNotes table based on a specific goal id. The GoalNotes table has a relation setup to the Goal Table as well.

I have three tables that look like the following:

Employee
Id,
FirstName,
LastName

GoalNotes
Id,
Goal,
Description,
Employee,
CreatedDt

Goal
Id,
Description,
CreatedDt

The query I am trying to use looks like this:

public List<GoalNotes> LoadGoalNotes(int goalId)
{
    var notes = from note in GoalNotes.Include("Employee")
                where Employee.Any(e => e.Id == note.Employee.Id)
                where note.Goal.Id == goalId
                orderby note.CreatedDt descending
                select note;

    return notes.ToList();
}

This method exists in an EntityContext file that contains a partial class for my entity object.
The issue appears to be in how I am trying to include the Employee reference. The query works if I remove the where Employee.Any(e => e.Id == note.Employee.Id) line (excluding the employee reference)

Thanks in advance!

  • 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-13T08:02:35+00:00Added an answer on May 13, 2026 at 8:02 am

    To include the employee, you just call Include — nothing else:

    var notes = from note in GoalNotes.Include("Employee")
                where note.Goal.Id == goalId
                orderby note.CreatedDt descending
                select note;
    

    The EF already understands the relationship between GoalNote and Employee (it’s in the EDMX), and you don’t need to duplicate this information in every query you write.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this

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.