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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:50:03+00:00 2026-06-09T04:50:03+00:00

It is possible to enable a cache that start ad the beginning of the

  • 0

It is possible to enable a cache that start ad the beginning of the request and ends at the end of the request ??

For some tables it will useful to enable a cache that not select the same record more that one time.

For example when I render a a partial more that one time the SELECT inside the partial are unnecessary.

Assume this snippet:

@foreach(var row in orders)
    {
        @{Html.RenderPartial("Order");}
    }

And the partial Order is:

<div>
        @session.Query<Langs>.SingleOrDefault(el => el.Id == "EN').Description
    </div>
<div>
    @Model.OrderID
</div>

It is possible to enable a cache that cache the “Langs” table only in the current session ?

Without cache I have N (Count of Orders) SELECT per request, otherwise with request cache I will have 1 SELECT per request.

Thank You!

  • 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-09T04:50:05+00:00Added an answer on June 9, 2026 at 4:50 am

    You should not be executing any database queries from within any view such as the partial you mentioned. This will almost always lead to a SELECT N+1 scenario.

    Follow an MVC pattern and do not mix the concerns. Any database queries should be initiated from a repository layer, then populate a model object that represents what data that the view needs, then pass that model to the view.

    With programming, anything is possible and there are always a million ways to do the same thing but following best practices and separation of concerns will save you from yourself and help you to build efficient, extendable and maintainable applications.

    To reiterate, whatever data your view needs access to, do all of that querying on the Controller-side of the MVC pattern. Doing it any other way is mixing concerns and leads to situations such as the one you are encountering.

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

Sidebar

Related Questions

Is it possible to enable RDS for ColdFusion 8 on a server that requires
Is it possible to enable/disable 'Application does not run in background'? I know I
is it possible to enable Airplay on an iPad app I've made that streams
How is it possible to enable the following JavaScript function, sending a POST request,
Anyone know if its possible to enable horizontal scrolling ONLY in a windows forms
In bash, I believe it is possible to enable tab completion on the terminal
Is it possible to programmatically enable Desktop Sync for a folder via the Box.com
Possible Duplicate: How to use enable_if to enable member functions based on template parameter
Possible Duplicate: How can I disable/enable UISearchBar keyboard's Search button? Can we disable the
Is it possible to disable or enable subgrid based on the selected value when

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.