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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:45:28+00:00 2026-06-17T18:45:28+00:00

As the title says, I´m using entity framework 4.0 for a financial application. I

  • 0

As the title says, I´m using entity framework 4.0 for a financial application. I have a winform where I list all the cheques (checks) I have. But in that form, the user can specify some filters.

enter image description here

If the user does not apply any filter, I just can make the query like this:

lista_cheques = db.Cheque.Include("Operacion").Include("Cliente").ToList();
datagridview.Datasource = lista_cheques;

That is simple. But when it applies filters, the problem gets bigger.

As you see, the user can use filter to see cheques (checks) of a specific client, dates, bank, CUIT number, check state, etc.

Now, my question is related to performance in the queries.

I was thinking on doing the filters separeted, like this:

lista_cheques = db.Cheque.Include("Operacion").Include("Cliente").Where(x => x.fecha_deposito == fecha).ToList();
lista_cheques = lista_cheques.Where(x => x.banco.id_banco = banco).ToList();
lista_cheques = lista_cheques.Where(x => x.Operacion.Cliente.id_cliente = id_cliente).ToList();

Translation:
fecha is date
Operacion is a group of checks
Cliente is client.

In this way, I´m doing a query, then, a query from that query result, then a new query from that new result and that goes on.

I think this way might have a big performance issues. I know that SQL server optimize queries. So, if I´m doing fragmented queries, the optimizer is not working properly.

The other way I thought about but it´s very tedious, is to create one big query to handle every possible filter selection.

For example, the other example would be like this:

lista_cheques = db.Cheque.Include("Operacion").Include("Cliente").Where(x => x.fecha_deposito == fecha && x.banco.id_banco = banco && x.Operacion.Cliente.id_cliente = id_cliente).ToList();

The big problem is that I will need lots of combinations to be able to handle all the filter posibilities.

Ok guys, now, will I have performace issues in the first code example? I doing there one big query to the database, and then I´m doing the query in the list of objects (which I think will be faster). I´m pretty new to this ORM, and this listing will have to handle a lot of registries..

I somebody can give me some advice? I made pretty much a mess explaining, hope you can understand..

  • 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-17T18:45:30+00:00Added an answer on June 17, 2026 at 6:45 pm
    lista_cheques = db.Cheque.Include("Operacion").Include("Cliente").Where(x => x.fecha_deposito == fecha).ToList();
    lista_cheques = lista_cheques.Where(x => x.banco.id_banco = banco).ToList();
    lista_cheques = lista_cheques.Where(x => x.Operacion.Cliente.id_cliente = id_cliente).ToList();
    

    Nearly perfect. Kill all those ToList and it is good.

    The ToList means SQL is evaluated, so if all 3 flters trigger, 2 and 3 are evaluated in memory.

    Kick the ToList away, and the different Where clauses get combined on the database.

    Standard LINQ 101. Works like a charm and is always nice to see.

    Then add as LAST line:

    lista_cheques = lista_cheques.ToList ();

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

Sidebar

Related Questions

Just what the question title says. I'm using SpringMVC, but that's irrelevant really. I
Title says most of it. I have a div container that holds all the
Title says it all. It's pretty easy from controllers - just using view_context. But
As the title says, I'm using Codeigniter with phil sturgeon - codeigniter-restserver framework. I've
I'm using JAAS to secure my web-application. As the title says, the problem is
As title says, I have a list of words, Like stopWords = [the, and,
The title says it all. I'm using a custom button to fetch the user's
As the title says, I am trying to add a list of integers using
As the title says, I am looking for a regex, using php code, that
Pretty much says it in the title. I have a class that looks something

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.