在 Silverlight RIA 服务中禁用 DomainContext / DomainDataSource 的缓存
我使用带有过滤器描述符的 DomainDataSource,但 DomainDataSource(或 DomainContext)似乎正在缓存旧数据,而不是用数据库中的新数据替换它。
<riacontrols:DomainDataSource
AutoLoad="True"
LoadSize="5"
Name="employeeDomainDataSource"
QueryName="GetEmployeeQuery" Width="0" DomainContext="{Binding EmployeeContext}">
<riacontrols:DomainDataSource.FilterDescriptors>
<riacontrols:FilterDescriptor IsCaseSensitive="False" PropertyPath="Name" Operator="Contains" Value="{Binding ElementName=NameFilter, Path=Text}"/>
</riacontrols:DomainDataSource.FilterDescriptors>
</riacontrols:DomainDataSource>
我还有一个 DataPager 控件。
假设用户A和B加载数据。用户 B 在编辑模式下更改员工姓名。用户 A 输入新名称作为过滤器,将获取数据,但会显示旧(缓存)名称。我使用了 fiddler,可以看到从数据库和 Web 服务返回了正确的数据。
有什么选项可以关闭此功能吗?
I use a DomainDataSource with filter descriptors, but it seems that the DomainDataSource (or DomainContext) is caching old data and not replacing it with fresh data from the database.
<riacontrols:DomainDataSource
AutoLoad="True"
LoadSize="5"
Name="employeeDomainDataSource"
QueryName="GetEmployeeQuery" Width="0" DomainContext="{Binding EmployeeContext}">
<riacontrols:DomainDataSource.FilterDescriptors>
<riacontrols:FilterDescriptor IsCaseSensitive="False" PropertyPath="Name" Operator="Contains" Value="{Binding ElementName=NameFilter, Path=Text}"/>
</riacontrols:DomainDataSource.FilterDescriptors>
</riacontrols:DomainDataSource>
I also have a DataPager control.
Suppose user A and B load the data. User B changes the Employee's Name in edit mode. User A types in that new name as filter, the data will be fetched but the old (cached) name is displayed. I used fiddler and I can see that the correct data is returned from the database and the webservice.
Is there any option where I can switch this off?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您需要在数据上指定 LoadOption。
我记不太清了,也找不到文档,但我相信您需要重写 DomainDataSource 上的 LoadingData 事件;并设置 args.MergeOption。尝试“刷新当前”。
I think you need to specify a LoadOption on the data.
I can't remember exactly, and I can't find the documentation, but I believe you need to override the LoadingData event on the DomainDataSource; and set the args.MergeOption. Try 'RefreshCurrent'.
您应该在 Load 方法中将 LoadBehavior 设置为 RefreshCurrent:
像这样:
context.Load(query, LoadBehavior.RefreshCurrent, loadOpt =>{},null);
http://msdn.microsoft.com/en-us/library/system.servicemodel.domainservices.client.loadbehavior%28v=vs.91%29.aspx
You should set LoadBehavior to RefreshCurrent in you Load method:
like this:
context.Load(query, LoadBehavior.RefreshCurrent, loadOpt =>{},null);
http://msdn.microsoft.com/en-us/library/system.servicemodel.domainservices.client.loadbehavior%28v=vs.91%29.aspx