在 Silverlight RIA 服务中禁用 DomainContext / DomainDataSource 的缓存

发布于 2024-12-13 01:45:00 字数 872 浏览 2 评论 0原文

我使用带有过滤器描述符的 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 技术交流群。

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

发布评论

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

评论(2

烦人精 2024-12-20 01:45:00

我认为您需要在数据上指定 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'.

仅一夜美梦 2024-12-20 01:45:00

您应该在 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

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