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

  • Home
  • SEARCH
  • 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 3945350
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:00:24+00:00 2026-05-20T01:00:24+00:00

I may have a misunderstanding but I was under the impression that having a

  • 0

I may have a misunderstanding but I was under the impression that having a IQueryable object which you can the do further filtering/ordering on only executes the relevant SQL once this is used in an enumerator if some sort eg/

IQueryable<Person> people = Person.All();
var peeps = people.Where(x = > x.Name = "John" && x.Surname == "Smith");
//At this point it generates a SQL and hits the DB?????
foreach (var person in peeps)  
{
...
}

Is it therefore possible to do this with a DataTable somehow? Instead of executing a SQL statement and putting it in a DataTable and then filtering out afterwards, you do the filtering and then it executes the SQL once enumerated over. This would obviously prevent all the data being returned to start with.

//Normal DataAdapter/DataTable fill approach
SqlDataAdapter da = new SqlDataAdapter(sql, cn);
da.Fill(dtConfig);
var result dtConfig.Rows.Cast<DataRow>()
      .Where(x => x.ItemArray.Any(
             y => y.ToString().IndexOf(param.sSearch, StringComparison.OrdinalIgnoreCase) >= 0));  //Search all columns
foreach(var row in result)
   {
     ....
   }

I don’t think its possible, hopefully you can prove otherwise but thought it might be quite neat if it could be done. I guess the problem is that the SQL will need to know what columns should be filtered on etc however I guess you could populate a DataTable via FillSchema then do the filtering/ordering and then the SQL gets executed on the enumeration?

  • 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-20T01:00:25+00:00Added an answer on May 20, 2026 at 1:00 am

    No; with DataTable it is the Fill operation that loads the data. After that, any LINQ you are doing is LINQ-to-Objects against the data already in memory. And I expect you are actually working against IEnumerable<T>, not IQueryable<T>.

    Even if you called .AsQueryable(), that is still only a smoke-and-mirrors trick to expose LINQ-to-Objects as IQueryable<T> (useful for code re-use) – it is still LINQ-to-Objects, and still operates only on the in-memory data (IQueryable<T> offers the possibility of composed execution – not the promise of it).

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

Sidebar

Related Questions

In PHP I can name my array indices so that I may have something
I may be greatly misunderstanding this threading scenario, but that's why I'm asking. What
You may have noticed that we now show an edit summary on Community Wiki
I have a CSV data file with rows that may have lots of columns
I'm merging in a remote branch that may have a lot of conflicts. How
I need to be able to take an arbitrary text input that may have
I think I may have a misunderstanding of <xsl:variable\> and <xsl:value-of\> so perhaps someone
I have a script being run in a document that may or may not
I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but
I may be misunderstanding how <include> and <merge> work, but according to Simple example

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.