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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:34:32+00:00 2026-06-16T15:34:32+00:00

It loads category but always with null parent. I want get hierarchy category with

  • 0

It loads category but always with null parent. I want get hierarchy category with given ID.

public static Category GetCategory(System.Guid ID, ActionLinkInfo AInfo)
        {
            Category category = null;

            using (TIKSN.STOZE.Data.StozeContext DContext = new Data.StozeContext())
            {
                var cats = from cat in DContext.Categories where cat.ID == ID select cat;

                foreach (Data.Category Cat in cats)
                {
                    category = new Category(Cat, Cat.Parent == null ? null : GetCategory(Cat.Parent.ID, AInfo), AInfo);
                }
            }

            return category;
        }
  • 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-16T15:34:33+00:00Added an answer on June 16, 2026 at 3:34 pm

    Try this:

    var cats = from cat in DContext.Categories.Include("Parent") where cat.ID == ID select cat;
    

    Or you can change your model, to include that ParentID as an integer in Category class:

    public class Category {
    
        /* (...) */
    
        public int ParentID { get; set; }
    
        [ForeignKey("ParentID")]
        public Category Parent { get; set; }
    }
    

    With that you’ll be able to get Cat.ParentID without loading whole Parent object from database.

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

Sidebar

Related Questions

When my Silverlight page loads, I want to set focus on a control. Simple
So, I have a page that loads and through jquery.get makes several requests to
I've implemented the Google API v3.0, but the documentation is always telling to put
I have added selectionDidChange event for my Ember.Select, but when my view loads it
I have tried several things but I can't get the MySQL query in my
I have a Datatable function like this public DataTable LoadCategory(SetupCategoryBO scBO) { DBConnect myConnection
Loads of answers on how to do it for a command line convert /path/to/file/file.pdf[3]
Dashcode loads a bunch of library listed in an array within part.js (function() {
The video player actually loads fine. My actual problem is when I refresh some
My page loads a TextView which is scrollable. Unfortunately the position appears to stick

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.