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

  • Home
  • SEARCH
  • 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 8223265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:37:59+00:00 2026-06-07T14:37:59+00:00

Lets say I have a entity model with three entities Item, ItemType and ItemPart.

  • 0

Lets say I have a entity model with three entities “Item”, “ItemType” and “ItemPart”. I’m trying to write a query that will pull the most recent item (by item.date) for each item type and include the parts in the query so I can use them after I get the results. I wrote a query that looks like this:

IQueryable<Item> results = context.Items
    .Include("ItemTypes")
    .Include("ItemParts")
    .Where(x => x.CurrentItem == true)
    .GroupBy(x => x.ItemType).Select(group => group.OrderByDescending(item => item.date).FirstOrDefault());

If I run it without the GroupBy line everything works and I can get the included items. If I add the GroupBy line the included objects are null. What am I doing wrong?

EDIT: did some more testing. It seems that it’s actually the select that’s breaking the includes. I guess they don’t get carried through the select. Now to find a way to build the query that will work.

  • 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-07T14:38:02+00:00Added an answer on June 7, 2026 at 2:38 pm

    I’m still not positive what was going on but somehow the select or group was breaking the includes I had. Anyway I just did a manual select by the group and got the most recent one then selected it into a new list.

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

Sidebar

Related Questions

Let's say I have an Entity in my Entity Framework Model that is named
Lets say we have the following entities. Entity A Entity B Entity C The
Lets say I have entities Article, Page and Category. I want entity Article to
Lets say I have a model, Article that has a large amount of columns
Lets say I have a core data model like this one: Item attributes: name
Lets say thay I have an entity with name A.It has two columns named
I have a question regarding foreign key in entity framework(EF4). Lets say i have
Let's say we have an entity that has attributes att1 and att2, where att1
Lets say I have a model similar to the one below, and I need
For example, lets say I have an entity called user and an entity called

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.