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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:30:55+00:00 2026-05-26T06:30:55+00:00

I have a table called products, and a mapping table called related_products which maintains

  • 0

I have a table called products, and a mapping table called related_products which maintains a parent-child relationship between products, e.g. product SKU_ID 1 has related products 2 & 3.

products
    +-----------------+
    |SKU_ID |   name  |
    +-----------------+
    | 1     |  Blah  
    | 2     |  Blah2  |
    | 3     |  Blah3  |
    +-----------------+

related_products
    +---------+------------+
    |SKU_ID_1 |   SKU_ID_2 |
    +---------+------------+
    | 1       |  2         |
    | 1       |  3         |
    | 3       |  2         |
    +---------+------------+

ORM Associations:
OneToMany relationship between products.SKU_ID and related_products.SKU_ID_1
OneToOne relationship between related_products.SKU_ID_2 and products.SKU_ID

This works fine in my application, but when I look at the returned objects in can see that because of the circular nature of the relationships, it seems like I’m returning too much data. Example: If I get all related products belonging to product SKU_ID=1, I get products 2 & 3 as expected. From those product objects I can also get their related products, then the related products of their related products and so on and so on.

Is this a problem? and if so how can I restrict the ‘depth’ of the returned associations? or have I done the mapping incorrectly in the first place?

  • 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-26T06:30:56+00:00Added an answer on May 26, 2026 at 6:30 am

    I think the association like this is fine.

    Since Linq2sql is lazy loading by default, there is no need to restrict the dept. You will only retrieve the related products as soon as you are using them in your code. (In case you are worried about loading too much, just profile the sql and you will see when/to what level they are loaded).

    You might run into problems in case you are eager loading using LoadWith LoadOptions on the DC. I would not know how to deal with that.

    Thanks to Jim Wooley I know that LoadOptions are not allowed with circular references….

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

Sidebar

Related Questions

Hi I have table called Sold Products which stores buying information for product &
Hey, I have a table called products that has a relationship with itself. This
I have a product table called products It has 3 fields (name,model(PK), and class_name).
I have a table called Products in my database. It has a couple of
I have a MySql table called reviews which stores a lot of product reviews,
I have a table called Product and a table called Shop. Each shop has
I Have a form to add a product into a database table called 'Products'
I have a table called order which has many order_items , each order_items is
I have an int field in my product table called product_stat which is incremented
I have a table called products, which contains two rows (plus others):price and mfr.

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.