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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:55:52+00:00 2026-05-17T16:55:52+00:00

Ok, bear with me… hadn’t done any Linq or Lambda until a couple of

  • 0

Ok, bear with me… hadn’t done any Linq or Lambda until a couple of days ago 🙂

I’m using C# and the ADO.NET Entity Framework. I want to query my model and get back a List of objects based on a relationship.

Here’s my code:

var query = db.Achievements.Join
 (
 db.AchievementOrganisations,
 ach => ach.AchievementId,
 ao => ao.AchievementId,
 (ach, ao) => new { Achievement = ach }
 );

var query2 = from s in db.Achievements
 join h in db.AchievementOrganisations
 on s.AchievementId equals h.AchievementId
 select s;

(sorry about the formatting)

My question is why does the first query, which I believe is a Lambda Expression, return an Anonymous Type:

{System.Data.Objects.ObjectQuery<<>f__AnonymousType1<MyApp.Models.Achievement>>}

…but the second query (a LINQ query) I get a strongly-typed value back:

{System.Data.Objects.ObjectQuery<MyApp.Models.Achievement>}

Why is this?

Cheers,

Ben

  • 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-17T16:55:53+00:00Added an answer on May 17, 2026 at 4:55 pm

    This bit is the problem in the first call:

    (ach, ao) => new { Achievement = ach }
    

    You’re creating a new anonymous type with an Achievement property of type Achievement.

    I suspect you just want:

    (ach, ao) => ach
    

    … although it’s slightly odd to do a join and ignore the table you’re joining with.

    Basically, whenever you see new { ... } that means an anonymous type. (Not to be confused with new[] { ... } which builds an array with an inferred element type, or new List<string> { ... } etc which will build a new List<string> with the given contents.

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

Sidebar

Related Questions

I am new to visual studio/asp.net so please bear with me. Using vs 2005
I'm still fairly new to ASP.NET development so bear with me. I'm going to
bear with me, I've been using wxPython for all of one day now. Short
I am new to JavaScript OO programming please bear with me for any ambiguities.
(Bear with me, I promise this gets to shebang and windows.) I have about
Bear with me while I explain my question. Skip down to the bold heading
Please bear with me, I'm just learning C++. I'm trying to write my header
A longwinded question - please bear with me! I want to programatically create an
A beginner question, bear with me: I'm just wondering under what circumstances one should
Ok, bear with me guys and girls as I'm learning. Here's my question. I

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.