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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:46:06+00:00 2026-06-10T14:46:06+00:00

When I execute: var t = db.Table1.OrderBy(x => x.Name).ToList(); In SQL profiler, this is

  • 0

When I execute:

var t = db.Table1.OrderBy(x => x.Name).ToList();

In SQL profiler, this is the translated SQL:

SELECT 
[Extent1].[ID] AS [ID], 
[Extent1].[Name] AS [Name]
FROM [dbo].[Table1] AS [Extent1]
ORDER BY [Extent1].[Name] ASC

Which is correct.

However, if I pass a selector function to OrderBy:

Func<Table1, string> f = x => x.Name;
var t = db.Table1.OrderBy(f).ToList();

The translated SQL is:

SELECT 
[Extent1].[ID] AS [ID], 
[Extent1].[Name] AS [Name]
FROM [dbo].[Table1] AS [Extent1]

The orderby is totally not translated.

What’s the problem? They are the same lambda function, the only difference is in the 2nd case, it is first assigned to a variable.

  • 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-10T14:46:08+00:00Added an answer on June 10, 2026 at 2:46 pm

    Cause in a IQueryable world, you need an Expression<Func<TModel, TValue>> as the OrderBy’s extension parameter, not a Func<TModel, TValue>

    http://msdn.microsoft.com/en-us/library/system.linq.queryable.orderby

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

Sidebar

Related Questions

When I execute this query: Dim Var Var = ("select max(Autonumber) from tblAutonumber") DoCmd.RunSQL
I want to execute a query like this var result = from entry in
I try to execute this query $qb = $this->_em->createQueryBuilder(); $qb->select(array('c', 'ld')) ->from('Model\Entity\Company', 'c') ->leftJoin('c.legaldetails',
I have this query var hql = @from Table1 tbl1 left join fetch tbl1.Table2;
With this code: var db = google.gears.factory.create('beta.database'); db.open('cominar'); db.execute('CREATE TABLE IF NOT EXISTS Ajax
Here's a LINQ statement that I am trying to execute var usersQuery = from
I have a problem with JavaScript magic. When I execute this code: var page
cursor.execute(SELECT user_id FROM myapp_location WHERE\ GLength(LineStringFromWKB(LineString(asbinary(utm), asbinary(PointFromWKB(point(%s, %s)))))) < %s\ ,(user_utm_easting, user_utm_northing, 500)); This
I execute SQL scripts to change the database schema. It looks something like this:
my $sth = $dbh->prepare(SELECT id FROM user WHERE group == '1' ORDER BY id

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.