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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:08:09+00:00 2026-05-20T12:08:09+00:00

I have a view that calls on four different partial views (.ascx) to populate

  • 0

I have a view that calls on four different partial views (.ascx) to populate a portion of the view via RenderAction call. Each of the partial views use the same view model, but each returns a different set of data via their own EF query in the underlying model. As you would assume from the sharing of the viewmodel, the partial views all return pretty much the same type of information — the difference is in the filtering. E.g. “New Products” vs. “Popular Products” vs. “Recommended Products”, etc.

I’m getting the data that I want, but I need to address the structure because my performance is pretty poor. The performance of each individual query doesn’t seem too bad (I’ve used LinqPad and tested the generated SQL in SQL Server and the performance is great). However, altogether, the page load time is pretty poor as I switch categories and reload the page.

Rather than calling 4 queries against the SQL server, can I call one that pulls everything (for all 4) and then filter the results into the individual partial views? Would this be better?

Many thanks for your suggestions/advice.

  • 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-20T12:08:10+00:00Added an answer on May 20, 2026 at 12:08 pm

    Yes. Doing one query and filtering would be much better.

    List<Widgets> widgetsFromQuery = (from w in db.Widgets 
    where w.Name.EndsWith("-sprocket") || 
    w.Name.EndsWith("-seat") || 
    w.Name == "toaster"
    select c).ToList();
    

    Calling ToList() at the end, forces Linq to perform the query immediately.

    Then you use widgetsFromQuery as your Model, and in each view, filter like this:

    var filteredModel = Model.Select(w => w.Name.EndsWith("-sprocket"));
    var filteredModel = Model.Select(w => w.Name.EndsWith("-seat"));
    var filteredModel = Model.Select(w => w.Name == "toaster"));
    

    Further performance enhancements would be something like:

    1) Cache the output of the query in the session (if it’s user specific) or application cache if not.

    2) Make each view tied to an action, load with AJAX, and use output cache attributes on the actions.

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

Sidebar

Related Questions

To be more specific, I have an app that has multiple tableViews that drill
I have inherited a piece of Javascript that uses the Google Feed API. It
I have a CoreDataUtilities class with a class method that saves a managed object
Suppose I have a page called view.php, if I give an argument like view.php?q=fruit,
I'm developing a multi device App with separate views for iPhone and iPad. Within
i have just started programming for android and i have a little question i
I was wondering if the following is an accepted way to switch views? AppDelegate.m
I have written a program in C# using Visual Studio 2010. At current it
I'm looking for profilers that support per request profiling statistics, ideally along the programs
I've been able to successfully return a model to a view and display the

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.