在 asp.net 和 ado.net 中缓存

发布于 2024-10-04 10:18:21 字数 283 浏览 0 评论 0 原文

我的数据库中有一个税表,可能每年更改一次。我们的 asp.net 应用程序具有根据客户所在的省/州查询数据库中税费的计算。我想避免那些往返。有没有办法可以在 Entity Framework 4 中使用缓存?因此,我想要基于 edmx 中的税表的实体,但是当我对其执行 LINQ 查询时,我不希望它进入数据库,除非缓存已过期。我将如何实现这个目标?

我以前没有使用过 ASP.NET 数据缓存,因此非常感谢有关该概念的一些详细信息。我已阅读有关应用程序数据缓存的 msdn 文档,但我只是想知道如何以优雅的方式使其与 EF4 一起工作。

I have a taxes table in the database which changes maybe once a year. our asp.net application has calculations that query the database for taxes based on the customer's province/state a lot. I would like to avoid those round trips. Is there a way I can use caching with Entity Framework 4? So I want the entity based on the taxes table in my edmx, but when I perform LINQ queries against it, I don't want it to go to the database unless the cache has expired. How would I accomplish this?

I haven't worked with asp.net data caching before, so some details on the concept would be highly appreciated. I have read the msdn documentation on application data caching, but I'm just wondering how to make this work with EF4 in an elegant manner.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

超可爱的懒熊 2024-10-11 10:18:21

您可以为此使用文件基础缓存。就像您必须在表上创建一个触发器,它将修改特定位置上的文件,然后您可以从 ASP.NET 代码添加文件上的缓存依赖项。因此,除非表中发生任何更改,否则您必须从缓存中获取数据,如果文件发生更改,那么它将验证缓存并从数据库中获取数据。

或者,

如果您使用 SQLServe 作为后端,则可以使用 SQL 缓存依赖功能。

以下是一些可能对您有帮助的链接。

http://www.15seconds.com/issue/031229.htm

http://www.c-sharpcorner.com/uploadfile/vishnuprasad2005/implementingcachinginasp .net11302005072210am/implementingcachinginasp.net.aspx

以下是实体框架中对缓存的一些支持

http://blogs.msdn.com/b/efdesign/archive/2008/07/09/transparent-caching-support-in-the -entity-framework.aspx

http://www.andrewdothay .net/blog/2009/01/28/LINQAndTheSqlCacheDependency.aspx

You can use file base caching for that. Like you have to create a trigger on the table which will modify files on a specific location and then you can add cachedependancy on file from asp.net code. So until and unless any changes occurred in table you have to fetch data from the cache if file changes then it will validate cache and data will be fetch from the database.

Or

You can SQL Cache dependancy feature if you are using SQLServe as your backend.

Here are the some links that might help you.

http://www.15seconds.com/issue/031229.htm

http://www.c-sharpcorner.com/uploadfile/vishnuprasad2005/implementingcachinginasp.net11302005072210am/implementingcachinginasp.net.aspx

here are some support for caching in entityframework

http://blogs.msdn.com/b/efdesign/archive/2008/07/09/transparent-caching-support-in-the-entity-framework.aspx

http://www.andrewdothay.net/blog/2009/01/28/LINQAndTheSqlCacheDependency.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文