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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:42:15+00:00 2026-06-17T23:42:15+00:00

I am trying to run this query, where I try to fetch categories and

  • 0

I am trying to run this query, where I try to fetch categories and there sub categories

studentCont.ContinuumCategories = db.continuumcategorymasters
    .Where(x => x.AssessmentId == assessmentId && x.ContinuumCategory != "other")
    .Select(x => new ContinuumCategory()
    {
        AssessmentId = x.AssessmentId,
        ContinuumCategoryId = x.ContinuumCategoryId,
        NativeAppid = x.NativeAppCategoryId,
        score = 0,
        ContinuumCategoryName = x.ContinuumCategory,
        ContinuumSubCategories = x.continuumsubcategorymasters
            .Select(csc => new ContinuumSubCategory
            {
                ContinuumSubCategoryId = csc.ContinuumSubCategotyId,
                ContinuumSubCategoryName = csc.ContinuumSubCategotyName,
                NativeAppsubid = csc.NativAppSubCategotyId
            })
    })
    .ToList();

Currently the field ContinuumCategory.ContinuumSubCategories is of type List so this query gives me a compile time error that it cannot convert IEnumerable to list, ofcourse it cannot.

And as linq does not recognize ToList method so I cannot even use that inside my query.

I can solve my problem by changing the type of ContinuumCategory.ContinuumSubCategories to IEnumerable but I have already used this field in many places where it uses List.Add method so I will have to replace all the Add methods to IEnumerable.Concat, so this can be tedious.

Is there any workaround to directly get the list of continuum sub categories from linq query only?

Edit:

when I use this query(used ToList() method inside query for ContinuumSubCategories)

studentCont.ContinuumCategories = db.continuumcategorymasters
    .Where(x => x.AssessmentId == assessmentId && x.ContinuumCategory != "other")
    .Select(x => new ContinuumCategory()
    {
        AssessmentId = x.AssessmentId,
        ContinuumCategoryId = x.ContinuumCategoryId,
        NativeAppid = x.NativeAppCategoryId,
        score = 0,
        ContinuumCategoryName = x.ContinuumCategory,
        ContinuumSubCategories = x.continuumsubcategorymasters
            .Select(csc => new ContinuumSubCategory
            {
                ContinuumSubCategoryId = csc.ContinuumSubCategotyId,
                ContinuumSubCategoryName = csc.ContinuumSubCategotyName,
                NativeAppsubid = csc.NativAppSubCategotyId
            }).ToList()
    })
    .ToList();

I get this exception

 LINQ to Entities does not recognize the method 'System.Collections.Generic.List1[BusinessObjects.ContinuumSubCategory] ToList[ContinuumSubCategory]
    (System.Collections.Generic.IEnumerable1[BusinessObjects.ContinuumSubCategory])' method, and this method cannot be translated into a store expression.
  • 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-17T23:42:16+00:00Added an answer on June 17, 2026 at 11:42 pm

    Don’t call ToList() on the inner query (the one for ContinuumSubCategories)

    Split your query into two parts with ToList() in-between:

    studentCont.ContinuumCategories = db.continuumcategorymasters
        .Where(x => x.AssessmentId == assessmentId && x.ContinuumCategory != "other")
        .ToList()  // Fetch all the data from the db
        .Select(x => new ContinuumCategory
        {
            AssessmentId = x.AssessmentId,
            ContinuumCategoryId = x.ContinuumCategoryId,
            NativeAppid = x.NativeAppCategoryId,
            score = 0,
            ContinuumCategoryName = x.ContinuumCategory,
            ContinuumSubCategories = (x.continuumsubcategorymasters
                .Select(csc => new ContinuumSubCategory
                {
                    ContinuumSubCategoryId = csc.ContinuumSubCategotyId,
                    ContinuumSubCategoryName = csc.ContinuumSubCategotyName,
                    NativeAppsubid = csc.NativAppSubCategotyId
                })).ToList()
        }).ToList();
    

    Does it work?

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

Sidebar

Related Questions

I'm trying to run this simple query: try { $dsn = mysql:host=localhost;dbname:mydb; $PDO =
Hi I am trying to run this query in SQL but it is not
I'm currently trying to run a LINQ query over a MS SQL database. This
Hey guys I am getting this exception when trying to run the query Column
I'm trying to run this query: Result.where('link = #{site}').present? where site is a string.
When I try to run this query in Access through the ODBC interface into
So what I'm trying to do is: Run this query: SELECT FW_ArtSrcLink FROM FW_ArtSrc
I'm trying to run this code but this error appear: Uncaught TypeError: string is
I'm trying to run this script that basically reads/interprets text in from a textfile
Currently I'm trying to run this powershell script: Param ( $websiteName, $physicalPath ) import-module

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.