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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:55:57+00:00 2026-06-12T07:55:57+00:00

I have function that will generate breadcrumbs format for my category e.g. Root->Children .

  • 0

I have function that will generate breadcrumbs format for my category e.g. Root->Children. It works because when I use it in my view it does work and doing its job. However I cannot cast it inside LINQ query.

Can someone explain how can I cast this particular function inside LINQ query? I’ve tried getting data and then setting it in foreach loop but it said that property is read only.

Function is Infrastructure.CategoryHelpers.Breadcrumbs({id}) it will return string.

Calling function

public dynamic List()
{
    var categories = _db.Categories.Select(x => new {
        ID = x.ID,
        Breadcrumbs = Infrastructure.CategoryHelpers.Breadcrumbs(x.ID, -1, ""), // this method cannot be translated into a store expression
        Name = x.Name,
        ItemCount = x.Items.Count
    });

    foreach (var c in categories)
    {
        // c.Breadcrumbs = Infrastructure.CategoryHelpers.Breadcrumbs(c.ID); // Value is read only
    }

    return Json(categories, JsonRequestBehavior.AllowGet);
}

Error

LINQ to Entities does not recognize the method ‘System.String
Breadcrumbs(Int32, Int32, System.String)’ 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-12T07:55:58+00:00Added an answer on June 12, 2026 at 7:55 am

    You should be able to use AsEnumerable() which makes Linq evaluate the rest of the expression locally;

    var categories = _db.Categories.Select(x => new { 
        ID = x.ID,                                    // This select is done in DB
        Name = x.Name,
        ItemCount = x.Items.Count
    })
    .AsEnumerable()                                   // Get result to LINQ to Objects                                   
    .Select(x => new {                 
        ID = x.ID,                                    // This select is done in memory.
        Breadcrumbs = Infrastructure.CategoryHelpers.Breadcrumbs(x.ID, -1, ""),
        Name = x.Name,
        ItemCount = x.ItemCount
    });
    

    Note that you need to do all filtering (columns/Where expression/GroupBy/OrderBy) that you want done by the database before the AsEnumerable() call, since that call will fetch what is set up until then to a local IEnumerable, and do the rest of the operations on that using Linq to Objects.

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

Sidebar

Related Questions

Hi I have a function that will generate a random string which works fine.
I have a function that will will generate a dataset and create an xml
I have a function that will parse some data coming in. My problem is
I have a function that will allow me to edit the manager property of
I currently have a function that will create X tasks of a function based
I have created a function that will return the string path from my DB.
I have a javascript function that will show the image you're about to upload
I want to have a jquery function that will be activated when any checkbox
I have a binary search function that will search for a word in an
I have problem with fancybox. I want to write a function that will run

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.