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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:02:16+00:00 2026-05-18T05:02:16+00:00

dataGridView1.DataSource = (from x in db.Employees where x.FirstName.Contains(textBox1.Text) select x); I am using the

  • 0
dataGridView1.DataSource = (from x in db.Employees
                            where x.FirstName.Contains(textBox1.Text)
                            select x);

I am using the above expression in my txtSearch_TextChanged event to filter the results real time. Does this call the Database every time a key is pressed to get the results OR are the results cached in the memory in some way and filtered and returned? Is this is the correct way of doing some real time filter like this in LINQ?

Northwind db = new Northwind(@"Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True");


private void txtSearch_TextChanged(object sender, EventArgs e)
    {

        dataGridView1.DataSource = (from x in db.Employees
                                    where x.FirstName.Contains(textBox1.Text)
                                    select x);

    }
  • 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-18T05:02:16+00:00Added an answer on May 18, 2026 at 5:02 am

    Yes… if you call that every time a key is pressed, the database is being queried every time a key is pressed.

    But it’s worse than that – LINQ is having to compile that expression into SQL every time, and that’s a significant amount of work, too.

    So no – that is not the correct way to do it. You should cache the data on the client first to do the auto complete… or at least only start pulling (and then cache) after two characters or so, so you can limit the results to cache.

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

Sidebar

Related Questions

I have a DataGridView that displays data from a MS Access database. I'm using
I have a datagridview and attached list of Employees to it, somthing like this:
I have a custom IBinding List which raises the ListChanged event. I would like
This is my code: private void button1_Click(object sender, EventArgs e) { DataTable table =
Software I use: C#, VS-2005. I have a populated combobox in datagridview. I have
I have a winForms DataGridView bound to a List<MyObjectType> . My problem is that
I have a DataGridView bound to a DataSet. I only want a selection of
This is probably easy, but I couldn't find an answer anywhere. I'm filling a
I've started a new job this week and am trying to get my head
This a data binding question in C#. I have a simple Person class: public

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.