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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:11:15+00:00 2026-05-13T06:11:15+00:00

I’m new to LINQ so apologies if this is a simple answer. I’m trying

  • 0

I’m new to LINQ so apologies if this is a simple answer. I’m trying to do a SQL join and have the following code based on examples I’ve seen on SO and elsewhere:

var query = from e in db.Events
    join ec in db.EventCategories on e.ID equals ec.EventID
    join c in db.Categories on ec.CategoryCode equals c.CategoryCode
    join ep in db.EventParticipants on e.ID equals ep.EventID
    join p in db.Participants on ep.ParticipantCode equals p.ParticipantCode
    select new { e, ec, c, ep, p };

This executes fine and when I run the debugger I can expand the Object and see that the query ran successfully. However, when I try to execute query.ToList() I can’t cast this into anything usable because it says that the list returned by query.ToList() is System.Collections.Generic.List.

Method #2:
Based on my own thoughts I tried creating the following struct:

public struct CalendarItem
    {
        public Event e;
        public EventCategory ec;
        public Category c;
        public EventParticipant ep;
        public Participant p;

        public CalendarItem(Event E, EventCategory EC, Category C, EventParticipant EP, Participant P)
        {
            e = E;
            ec = EC;
            c = C;
            ep = EP;
            p = P;
        }
    }

And then modifying the LINQ command to the following:

var query = from e in db.Events
    join ec in db.EventCategories on e.ID equals ec.EventID
    join c in db.Categories on ec.CategoryCode equals c.CategoryCode
    join ep in db.EventParticipants on e.ID equals ep.EventID
    join p in db.Participants on ep.ParticipantCode equals p.ParticipantCode
    select new CalendarItem(e, ec, c, ep, p);

In Visual Studio this checks out and it allows me to compile and everything looks great (i.e. I can loop over the list of CalendarItems), but I get a runtime error on query.ToList(): The member ‘e’ has no supported translation to SQL.

  • 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-13T06:11:15+00:00Added an answer on May 13, 2026 at 6:11 am

    I’d make my CalandarItem a class with automatic properties:

    public class CalendarItem
    {
            public Event E{get;set;}
            public EventCategory EC{get;set;}
            public Category C{get;set;}
            public EventParticipant EP{get;set;}
            public Participant P{get;set;}
    }
    

    and use a object initializer on the select:

    var query = from e in db.Events
        join ec in db.EventCategories on e.ID equals ec.EventID
        join c in db.Categories on ec.CategoryCode equals c.CategoryCode
        join ep in db.EventParticipants on e.ID equals ep.EventID
        join p in db.Participants on ep.ParticipantCode equals p.ParticipantCode
        select new CalendarItem{E=e, EC=ec, C=c, EP=ep, P=p};
    

    I know this will work because I just happened to write a very similar bit of code about 2 minutes ago!

    • 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’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.