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

  • Home
  • SEARCH
  • 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 923447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:11:42+00:00 2026-05-15T19:11:42+00:00

Assuming I have the following schema table A: ID int primary key value varchar(255)

  • 0

Assuming I have the following schema

table A:
ID int primary key
value varchar(255) not null

table B:
ID int primary key
AID foreign key refences A (ID)
name varchar(40) not null

now when I execute the following subsonic linq

var items = 
from a in A.All() 
where any-condition select a;

all is fine.

the killer is when I do the following

for(var item in items)
{
   for(var nestedItem in item.B) // troubling!
   {
     DoSomething(nestedItem)
   }
}

I am not very familiar with the inner workings, But I am pretty sure it does additional trips to the DB to get the joined table rows.

Can you please tell me how can I avoid such expensive trips?

  • 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-15T19:11:43+00:00Added an answer on May 15, 2026 at 7:11 pm

    This is a classic problem with ORMs – SELECT N + 1. What you’re coming up against is Lazy vs. Eager loading and in this case you need to either do some kind of outer join (using the query tool) or pull B into a list.

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

Sidebar

Related Questions

I have the following table schema: CREATE TABLE [Foo]( [id] [int] NOT NULL, [name]
Assuming I have a table SomeTable with the following data: Primary Key Column1 Column2
Assuming you have the following database table: create table Names ( Id INT IDENTITY
Assuming I have the following delegate: public delegate int TestD(int p); Is there any
Suppose I have the following schema: Table: Showing showing_id movie_id theater_id show_date show_time Table:
I have a MySQL table with following setup: CREATE TABLE IF NOT EXISTS `coords`
Assuming I have the following repeater. <asp:Repeater ID=MyRepeater runat=server onitemdatabound=MyRepeater_ItemDataBound> <FooterTemplate> </table> <asp:Button ID=btnPrevious
assuming that I have following xml: <ns5:OrderTotal> <ns5:Name>AmountPaid</ns5:Name> <ns5:Description>Payment Received</ns5:Description> <ns5:SortOrder>4</ns5:SortOrder> <ns5:Value>16.95</ns5:Value> </ns5:OrderTotal> <ns5:OrderTotal>
Assuming I have the following table: AAAAAA AAAAAB CCCCCC How could I craft a
Assuming I have the following table: <table> <thead> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column

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.