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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:55:20+00:00 2026-05-31T08:55:20+00:00

What I want is pretty simple conceptually but I can’t figure out how it

  • 0

What I want is pretty simple conceptually but I can’t figure out how it would be best to implement such a thing.

In my web application I have services which access repositories which access EF which interacts with the SQL Server database. All of these are instanced once per web request.

I want to have an extra layer between the repositories and EF (or the services and the repositories?) which statically keeps track of objects being pulled from and pushed to the database.

The goal, assuming DB-access is only accomplished through the application, would be that we know for a fact that unless some repository access EF and commits a change, the object set didn’t really change.

An example would be:

Repository invokes method GetAllCarrots();

GetAllCarrots() performs a query on SQL Server retrieving a List<Carrot>, if nothing else happens in between, I would like to prevent this query from being actually made on the SQL Server each time (regardless of it being on a different web request, I want to be able to handle that scenario)

Now, if a call to BuyCarrot() adds a Carrot to the table, then I want that to invalidate the static cache for Carrots, which would make GetAllCarrots(); require a query to the database once again.

What are some good resources on database caching?

  • 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-31T08:55:21+00:00Added an answer on May 31, 2026 at 8:55 am

    You can use LinqToCache for this.

    It allows you to use the following code inside your repository:

    var queryTags = from t in ctx.Tags select t;
    var tags = queryTags.AsCached("Tags");
    foreach (Tag t in tags)
    {
      ...
    }
    

    The idea is that you use SqlDependency to be notified when the result of a query changes. As long as the result doesn’t change you can cache it.

    LinqToCache keeps track of your queries and returns the cached data when queried. When a notification is received from SqlServer the cache is reset.

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

Sidebar

Related Questions

This seems pretty simple, but I can't seem to figure it out. I want
This seems pretty simple, but I can't figure it out. I'm new to javascript/
What I want to do seems pretty simple, but I can't find any answers
I want to do something pretty simple, but I'm not sure what the best
I want to do something pretty simple but have yet am having a hard
Guess this is pretty simple, but searching didn't help... I want an ExpandableListView, where
What I want to do is pretty simple. I would like to have sync
so i want to do something which seems pretty simple but is proving other
Seems pretty simple but I can't get it to work. I have two divs
Pretty simple one, but I can't find the answer. I'm building an app in

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.