使用 asp.net 缓存在 .dll 中?
我有一个网站,使用了用vs2010开发的dll。
在 dll 中,我有一个方法 C.GetData(int id)
,它返回我的对象的 IEnumerable
集合。当我使用中继器显示数据时,我看到“旧”数据。例如,在数据库中我有 name=Maurox
,但在 .aspx 页面中我看到 name=Pippo
这是更新前字段的旧值。
如果我使用相同的查询(从方法 C.GetDate
复制/粘贴),数据没问题,我在可能的页面上看到 name=Maurox。
这是一个例子:
使用 C.GetData() 我有这一行(错误)51 Via Roma Firenze 00100
使用“内联”linq(在代码后面复制/粘贴 linq 查询)我有:51
经由罗马佛罗伦萨 00101
查询很简单:
from c in db.ContattiRecapiti
join cc in db.Contatti on c.idcontatto equals cc.IDContatto
join aa in db.aspnet_Membership on cc.aspnet_UserId equals aa.UserId
where cc.aspnet_UserId == UserId && cc.Attivo == 1 && aa.IsApproved == true && c.attivo == 1
select c
我该如何解决这个问题?有缓存吗??
谢谢!
I have a site that uses a dll developed with vs2010.
In dll i have a method C.GetData(int id)
that return a IEnumerable
collection of my object. When i use a repeater to display data, i see the "old" data. For example, in the database I have name=Maurox
, but in .aspx page I see name=Pippo
that is the old value of field before update.
If i use the same query (copy/paste from method C.GetDate
) the data is ok, i see name=Maurox on may page.
Here is an example:
with C.GetData() i have this row (wrong) 51 Via Roma Firenze 00100
with "inline" linq (copy/paste linq query in code behind) i have: 51
Via Roma Firenze 00101
the query is simple:
from c in db.ContattiRecapiti
join cc in db.Contatti on c.idcontatto equals cc.IDContatto
join aa in db.aspnet_Membership on cc.aspnet_UserId equals aa.UserId
where cc.aspnet_UserId == UserId && cc.Attivo == 1 && aa.IsApproved == true && c.attivo == 1
select c
How i can fix this? Is there some cache??
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果使用 LINQ to SQL 或实体框架,则会有一个内部对象缓存,它是数据/对象上下文使用的工作单元模式的实现。您可以尝试调用 Refresh() 方法来查看如果它为您刷新数据...
另外,您如何存储数据/对象上下文?是全局存储它还是针对每个 LINQ 查询存储它?
If using LINQ to SQL or Entity Framework, there is an internal object cache, which is the implementation of the Unit of Work pattern that the Data/Object Context employs. What you could try to do is call the Refresh() method to see if it refreshes the data for you...
Also, how do you store your data/object context? Do you store it globally, or for each LINQ query?
您确定您正确调用了该函数吗???
请确保您调用了要显示的函数。您可能会在 ispostback 函数或其他函数中使用它。我不认为dll内有单独的缓存。浏览器缓存可能无法清除。另外,请刷新(ctrl+F5)页面后查看数据
Are you sure that you are calling the function properly???
Please make sure that you calling the function to display.. you may be used it within ispostback function or something else. I dont think there is a separate cache within dll. the browsers cache may not be cleared. Also, please check the data after refreshing(ctrl+F5) the page