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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:46:25+00:00 2026-05-11T09:46:25+00:00

To see my problem in action, visit www.apoads.com and hover over the Local Businesses

  • 0

To see my problem in action, visit http://www.apoads.com and hover over the ‘Local Businesses’ menu item. It’s a series of nested unordered lists generated from a db call. Go ahead and click on a few of the items underneath ‘Local Businesses’, you’ll see that most of the categories are empty (the site is very new).

Problem: I only want to show the categories that actually contain a local business. Here’s what my category schema looks like:

int BizCatID - PK,Identity (used in FK relation to the table named Biz) int? ParentID - BizCatID of this rows parentID, null means no parent nvarchar Name - name of the category nvarchar Caption - quick description of the category 

What I’ve tried: I’ve tried to update my LINQ query like so:

from c in db.BizCategories where c.ParentID != null && c.Bizs.Count() > 0 select c; 

That obviously won’t work, cause I’ll need the parent category to show if the child category contains a business. So I tried this:

from c in db.BizCategories where c.Bizs.Count() > 0 select c; 

This doesn’t work either, as parent categories will never have any businesses under them. So it seems like I’ll need to do some sort of inverse recursion, but I’m not sure how to do that.

Or, perhaps I’m making things to hard for myself and I need to change my db schemas?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T09:46:25+00:00Added an answer on May 11, 2026 at 9:46 am

    create classes to hold your information like so

    public class BusinessCat {     public string Name{get;set;}     public string Caption{get;set;}     public List<'dunno datatype'> Children{get;set;}; }  var results = from c in BizCategories     where c.ParentID == null         select new BusinessCat{             Name = c.Name,             Caption = c.Caption,             Children =  (from d in BizCategories                     where d.ParentID == c.BizCatID && d.Bizs.Count() > 0 select d).ToList()         } 

    and with this you have a list full of Children and you can simply iterate through it with a foreach.

    You can also do .Join() extension method for

    where d.ParentID == c.BizCatID && d.Bizs.Count() 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please go to: http://jlecologia.com/page1c.html to see the problem The top box look fine but
I've looked at this over and over again and I can't see the problem.
( see problem in action ) generally my problem is - I can add
See the problem in action: http://jsfiddle.net/krtGd/1/ I have an embedded SVG element in a
I have this problem with the menu floating over the border of the page.
I see this problem on and off again in my PHP coding, and I've
Does anyone see a problem with this, its not working saying bad file descriptor
I don't see this problem too often but I've got a .cshtml that uses
Please go here to see my problem, its within the card on the left
Problem: to see when computer makes approximation in mathematical calculations when I use Python

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.