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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:31:27+00:00 2026-05-30T18:31:27+00:00

I was working with a DataTable and noticed that Resharper recommended that I can

  • 0

I was working with a DataTable and noticed that Resharper recommended that I can convert a loop into a LINQ expression. I did so and it was rewritten in query expression syntax (simplified):

var test1 = from DataRow row in dt.Rows select row;

Personally, I prefer method syntax so rewrote it to this:

var test2 = dt.Rows.Select(row => row);

And it broke.

‘System.Data.DataRowCollection’ does not contain a definition for ‘Select’ and no
extension method ‘Select’ accepting a first argument of type ‘System.Data.DataRowCollection’ could be found (are you missing a using directive or an assembly reference?)

Since query expression are translated to method calls, why is that the first works but not the second? I expected either both or neither to work which is obviously not the case.

  • 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-30T18:31:28+00:00Added an answer on May 30, 2026 at 6:31 pm

    The first has an explicitly typed range variable, so it’s actually compiled to:

    var test2 = dt.Rows.Cast<DataRow>();
    

    (There’s no need for the Select as this is a degenerate query expression (the select is a no-op.)

    An alternative is to call AsEnumerable from DataTableExtensions. I believe there may be some performance benefits in that, but only in some cases:

    var test2 = dt.AsEnumerable();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with a SqlCommand in C# I've created a query that contains a IN
Can A datatable somehow be passed into SQL Server 2005 or 2008 ? I
Im working on asp.net website. In some pages I'm saving the datatable into chache
I'm storing DataTable in ASP .NET Cache property. Operations that can be done on
Recently I switched to mojarra from myfaces and noticed that primefaces datatable checkbox multiple
Im trying to retrieve a datatable that I put into a session variable, however
I am dumping a cvs file into a datatable. I am able to loop
I am trying to loop through a datatable, that will pass information to my
I am working with VB.NET.. i have a DataTable called QUESTION, containing 3 fields:
Working on a project that parses a log of events, and then updates a

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.