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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:49:11+00:00 2026-05-23T15:49:11+00:00

so first my entities the problem i want to have a page with all

  • 0

so first my entities

Entities

the problem i want to have a page with all the story titles and their types

there are three stories LongStory , CoOpStory, GenericStory

the generic story is associated with StoryType for the type of the generic story

i have two problems

first when i want to check if the story is LongStory or CoOpStory i have to get all the entity and check the entity type if it is LongStory then do something , i don’t know how to retrieve some data [only the title] and check the type

my second problem like i said i want to have a page with all the story titles and their types i don’t know how to do that without making a lot of queries , i can’t make a join to the StoryType table because it must be GenericStory to be associated with that , so what i do first get all the stories then do an extra query for every GenericStory to get the type

  • 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-23T15:49:12+00:00Added an answer on May 23, 2026 at 3:49 pm

    You are looking of OfType and Concat extension methods.

    To get only LongStory instances you just need to call:

    var longStories = context.Stories.OfType<LongStory>().ToList();
    

    To get your bigger query it is little bit more complex. You can either try:

    var allStories = context.Stories
                            .OfType<GenericStory>()
                            .Include("StoryType") // I'm not sure how this works with concat
                            .Concat(
                                 context.Stories.OfType<LongStory>.Concat(         
                                      context.Stories.OfType<CoOpStory>()));
    

    Or you can do a projection:

    var allStories = context.Stories
                            .OfType<GenericStory>()
                            .Select(s => new { s.Title, s.StoryType.Name })
                            .Concat(
                                 context.Stories
                                        .OfType<LongStory>
                                        .Select(s => new { s.Title, "LongStory" })
                                        .Concat(         
                                            context.Stories
                                                   .OfType<CoOpStory>()
                                                   .Select(s => new { s.Title, Type })));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a schema which has 6 different types of entities, but they all
I'm using Entity Framework Code First v 4.3.0 I have a two entities with
I have this query that gets executed though Linq to Entities. First time the
I have a following problem with entity mapping in JPA. I have two entities,
I have strings of the following kind: asdf:0123-456-789:USB0::0x1234::0x9ABC::0123-456-789::INSTR First, there is the name asdf
First, we create classes that represent db entities, ok, done. Let's say we use
In model first, when we create a one to many relationship between two entities,
I googled around and learned that Lift encourages view-first development, lazy loading of entities,
First of all, this isn't for a keylogger, it's for an input in a
first take a look on this picture from localScope app : i have 2

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.