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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:21:10+00:00 2026-05-25T11:21:10+00:00

I am very new to LINQ to SQL, so please forgive me if its

  • 0

I am very new to LINQ to SQL, so please forgive me if its a layman sort of question.

I see at many places that we use "select new" keyword in a query.
For e.g.

var orders =  from o in db.Orders select new {
                o.OrderID,
                 o.CustomerID,
                 o.EmployeeID,
                 o.ShippedDate
           }

Why don’t we just remove select new and just use "select o"

var orders =  from o in db.Orders select o;

What I can differentiate is performance difference in terms of speed, i.e. then second query will take more time in execution than the first one.

Are there any other “differences” or “better to use” concepts between them ?

  • 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-25T11:21:11+00:00Added an answer on May 25, 2026 at 11:21 am

    With the new keyword they are building an anonymous object with only those four fields. Perhaps Orders has 1000 fields, and they only need 4 fields.

    If you are doing it in LINQ-to-SQL or Entity Framework (or other similar ORMs) the SELECT it’ll build and send to the SQL Server will only load those 4 fields (note that NHibernate doesn’t exactly support projections at the db level. When you load an entity you have to load it completely). Less data transmitted on the network AND there is a small chance that this data is contained in an index (loading data from an index is normally faster than loading from the table, because the table could have 1000 fields while the index could contain EXACTLY those 4 fields).

    The operation of selecting only some columns in SQL terminology is called PROJECTION.

    A concrete case: let’s say you build a file system on top of SQL. The fields are:

    • filename VARCHAR(100)
    • data BLOB

    Now you want to read the list of the files. A simple SELECT filename FROM files in SQL. It would be useless to load the data for each file while you only need the filename. And remember that the data part could “weight” megabytes, while the filename part is up to 100 characters.

    After reading how much “fun” is using new with anonymous objects, remember to read what @pleun has written, and remember: ORMs are like icebergs: 7/8 of their working is hidden below the surface and ready to bite you back.

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

Sidebar

Related Questions

I'm very new to using Linq-to-SQL, that's why I'm asking this question. I've searched
I am working on a new project that needs to use Linq To SQL
I'm VERY new to Linq. I have an application I wrote that is in
I'm trying to translate this SQL sentence to LINQ but I'm very new in
I have a very unusual problem. I have an ASP.NET application that uses LINQ-to-SQL
i'm very new to linq to sql and in need of a little assistance.
Right off the bat I'm very new to LINQ to SQL (and C# in
i am a new linq to sql learner and this is my very first
I'm very new to Linq, I can find multi-line data reading examples everywhere (by
Very new to XSL (and XML for that matter), but I need to step

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.