【问题标题】:How to refresh collection on client?如何在客户端刷新集合?
【发布时间】:2009-06-02 13:34:24
【问题描述】:

我从服务器加载客户端数据:

var context = new WordsDomainContext();
context.LoadWords();

我根据需要在客户端使用我的集合 context.Words。它运作良好。 但出于某些原因,我想刷新我的 context.Words。当我再次调用 context.LoadWords() 新记录时,只需附加到当前集合。

我尝试使用MergeOption context.LoadWords(null, MergeOption.OverwriteCurrentValues, null),但没有效果。

如何清理我的 Words 集合并从服务器加载新数据?

【问题讨论】:

    标签: c# .net entity-framework wcf-ria-services


    【解决方案1】:

    您可能需要在使用 LoadWords() 之前调用它:

    context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.LoadWords);
    

    【讨论】:

      【解决方案2】:

      您可以使用以下方法从数据库中刷新客户端上的集合:

      collection.Load(MergeOption.OverwriteChanges);
      

      b.t.w - 集合是 EntityCollection 类型。

      【讨论】:

        猜你喜欢
        • 2020-06-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-22
        • 2013-10-27
        • 2017-01-11
        相关资源
        最近更新 更多