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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:17:16+00:00 2026-06-03T09:17:16+00:00

I am using Linq to SQl to query the data. When I write a

  • 0

I am using Linq to SQl to query the data. When I write a select query with order by and monitor in SQL Server Profiler it run the select command 2 times

  1. to Select the fields from the table
  2. to order the data.

It takes time when the data is huge. Is there any solution for this.

Updated:

from dc in dataContext.UserTable join 
m in dataContext.MonthLookups on dc.Month equals m.Month into sr 
from x in sr.DefaultIfEmpty() 
order by dc.UserName, dc.FirstName 
select new {dc, sr.MothName};

Updated:

SELECT 
 [Project1].[ UserName] AS [UserName], 
[Project1].[ FirstName] AS [FirstName], 
[Project1].[ MonthName] AS [MonthName], 
[Project1].[year] AS [year]
FROM ( SELECT 
     [Extent1].[UserName] AS [UserName], 
    [Extent1].[FirstName] AS [FirstName], 
    [Extent1].[year] AS [year], 
     [Extent2].[MonthName] AS [MonthName]
    FROM  [dbo].[DutySavingFin] AS [Extent1]
    LEFT OUTER JOIN [dbo].[MonthLookup] AS [Extent2] ON [Extent1].[Month] = [Extent2].[Month]
)  AS [Project1]
ORDER BY [Project1].[UserName] ASC, [Project1].[FirstName] ASC

Updated :

Preferred way :

SELECT 
     [Extent1].[UserName] AS [UserName], 
    [Extent1].[FirstName] AS [FirstName], 
    [Extent1].[year] AS [year], 
     [Extent2].[MonthName] AS [MonthName]
    FROM  [dbo].[DutySavingFin] AS [Extent1]
    LEFT OUTER JOIN [dbo].[MonthLookup] AS [Extent2] ON [Extent1].[Month] = [Extent2].[Month]
ORDER BY [Extent1].[UserName] ASC, [Extent1].[FirstName] ASC
  • 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-06-03T09:17:18+00:00Added an answer on June 3, 2026 at 9:17 am

    Your example above shows a single query. The nested query does not impact performance if that is what you mean…

    If you are working with a large set of data:
    1) Make sure you have indexes on DutySavingFin.Month, MonthLookup.Month, and DutySavingFin.UserName+DutySavingFin.FirstName.
    2) Add a where clause to filter down to the records you need, unless you really need all data in the table

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

Sidebar

Related Questions

I'm using Linq to sql to access an SQL Server. I try to write
Has anyone found/coded extension method that query data (using linq to sql ) in
I'm having trouble with a LINQ to SQL query getting the min value using
How to select all columns from tables in join using linq Sql: select CTRL_RUN_JOB.*,
using Linq-to-SQL I'd like to prefetch some data. 1) the common solution is to
I am using LINQ to SQL with Sql Server Compact Edition 3.5 and VS2008.
I am using Linq-to-SQL. Currently I am binding gridview through linq which query written
I am using linq with SQL CE, but for a simple query like this:
Consider this typical disconnected scenario: load a Customer object from SQL Server using LINQ
I have a Premiums table that I attempting to query using the following LINQ-to-SQL:

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.