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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:40:43+00:00 2026-06-18T11:40:43+00:00

I have a Game model that have many Organizer models attached to it. Here

  • 0

I have a Game model that have many Organizer models attached to it. Here are my models:

public class Organizer
{
    public int ID { get; set; }
    public string Name { get; set; }
    public List<Game> Games {get; set; }
}

public class Game
{
    public int ID { get; set; }
    public string Name { get; set;}
    public List<Organizer> Organizers { get; set; }
}

I’m trying to grab all the Games that contain a specific Organizer. For instance, I might have some data like this:

Game
ID    Name
--    ----
1     Soccer
2     Baseball

Organizer
ID    Name
--    ----
1     John
2     Barry

GameOrganizer
GameID    OrganizerID
------    -----------
1         1
2         1

And here’s the code I try to use:

Organizer thisOrganizer = db.Organizers.Single(o => o.ID == 1);

var gamesQuery = db.Games
    .Where(game => game.Organizers.Contains(thisOrganizer))
    .Select(g => new { ID = g.ID, Name = g.Name });

This gives me an error:

Only primitive types are supported in this context.

I understand what it means, but I can’t figure out how to express it in a different way. The closest I’ve come is:

var gamesQuery = db.Games
    .Where(game => game.Organizers
        .Any(gO => gO.ID == 1));

but that just returns nothing. I’ve looked everywhere but everything deals with string arrays that are already known in advance.

So, how can I express this without model objects?

  • 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-18T11:40:45+00:00Added an answer on June 18, 2026 at 11:40 am

    You need to declare also Games as (navigation) property of Organizer, then it will be just:

    db.Organizers.Single(o => o.ID == 1).Games;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many-to-many relationship between Game and Account models like below: class Account <
I have a problem with CI. I have a model: public function Game($id) {
I have written a checkers game model which has a Board object that holds
I have the following models: Game and Pick. There's a one to many association
I have two models : class Game before_save :update_teacher teacher end def update_teacher teacher.update_attribute(something,
I have a GAE datastore with 303 Game() entities. class Game(db.Model): title = db.StringProperty(required
I am making a game, and have a Game model and a User model.
I have a game that currently runs under Windows and Mac OS X and
I have a game engine that uses OpenGL for display. I coded a small
I have three models in a Rails application: Game represents an instance of a

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.