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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:52:39+00:00 2026-05-27T22:52:39+00:00

i need help to understand linq join. i found out a few topics related

  • 0

i need help to understand linq join. i found out a few topics related with this issue but i didnt found one with a good explanation of steps.

i normal query, i do this.

var q = from c in context.tableA
        select c;
        List<tableA> tableAList = q.ToList();

in q.ToList() its get executed the query, right?

here found some examples but i want to be clear about this,

 using (AdventureWorksEntities context = new AdventureWorksEntities())
 {
 ObjectSet<SalesOrderHeader> orders = context.SalesOrderHeaders;
 ObjectSet<SalesOrderDetail> details = context.SalesOrderDetails;

var query =
    from order in orders
    join detail in details
    on order.SalesOrderID equals detail.SalesOrderID
    where order.OnlineOrderFlag == true
    && order.OrderDate.Month == 8
    select new
    {
        SalesOrderID = order.SalesOrderID,
        SalesOrderDetailID = detail.SalesOrderDetailID,
        OrderDate = order.OrderDate,
        ProductID = detail.ProductID
    };

foreach (var order in query)
{
    Console.WriteLine("{0}\t{1}\t{2:d}\t{3}",
        order.SalesOrderID,
        order.SalesOrderDetailID,
        order.OrderDate,
        order.ProductID);
}
}

so from this example i can see that query can have more than 1 objetc but what about this "select new" ? is it called for each record in the DB ?

what type is that object? anyone i want or is order because is the first table in the query?

in case of the object is the first table, what happens if i need to have data that is not defined in this type of, i mean new attr.

other question, when is the query executed?

also, is this method good for response speed or are better solutions?

thx in advance. If there is a thread with this answers plz point me well.

  • 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-27T22:52:40+00:00Added an answer on May 27, 2026 at 10:52 pm

    in q.ToList() its get executed the query, right?

    yes

    what about this “select new” ? is it called for each record in the DB
    ?

    new is just a new anonymous object, the query is ran against your table normally.

    what type is that object? anyone i want or is order because is the
    first table in the query?

    it’s anonymous, you could do select new Order { though, if you have an Order class defined.

    in case of the object is the first table, what happens if i need to
    have data that is not defined in this type of, i mean new attr.

    You would have to select it or add the attribute/property to your object/class.

    other question, when is the query executed?

    In the foreach loop

    also, is this method good for response speed or are better solutions?

    Yes, it’s fine

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

Sidebar

Related Questions

I need your help to understand this better. This is my case. I have
I need an help to understand this problem I am facing...and apologies if it
I dont really understand about linq, can you help me with this query? SELECT
I need some help to understand analysing recursive algorithms. I quickly made this algorithm
i m new to solr so i really need someone to help me understand
Need help writing a script downloads data from google insight using c# this is
I need help to understand the following command. tar -cvf /dev/nst0 /home/user1 >> file1.log
Im pretty proficient in LINQ, but not in SQL. I understand cursors are horrible
Ok this one is might not have a straight forward answer but lets see.
I need help to understand how a function is working;: it is a recursive

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.