0

我已将 silverlight 项目从 4 升级到 5,现在在将数据加载到 DomainContext 时出现编译错误:

Context.Load(Context.GetMyEntityQuery(), LoadBehavior.RefreshCurrent, null, null);


The call is ambiguous between the following methods or properties: 

'System.ServiceModel.DomainServices.Client.DomainContext.Load<MyEntity>(System.ServiceModel.DomainServices.Client.EntityQuery<MyEntity>, System.ServiceModel.DomainServices.Client.LoadBehavior, System.Action<System.ServiceModel.DomainServices.Client.LoadOperation<MyEntity>>, object)
'System.ServiceModel.DomainServices.Client.DomainContext.Load          (System.ServiceModel.DomainServices.Client.EntityQuery,           System.ServiceModel.DomainServices.Client.LoadBehavior, System.Action<System.ServiceModel.DomainServices.Client.LoadOperation>,           object)' 

任何想法如何解决这个问题(我有> 100个这样的错误)?

编辑

像这样调用有助于:

Context.Load<MyEntity>(Context.GetMyEntityQuery(), LoadBehavior.RefreshCurrent, null, null);

罪魁祸首是这个重载(程序集 System.ServiceModel.DomainServices.Client.dll,v2.0.5.0)

[EditorBrowsable(EditorBrowsableState.Never)]
public virtual LoadOperation Load(EntityQuery query, LoadBehavior loadBehavior, Action<LoadOperation> callback, object userState);

连同这个

public LoadOperation<TEntity> Load<TEntity>(EntityQuery<TEntity> query, LoadBehavior loadBehavior, Action<LoadOperation<TEntity>> callback, object userState) where TEntity : Entity;

似乎后者就足够了,为什么要包括前者呢?无论如何,将进一步调查(似乎我参考了最新的 ria services 1.0 SP2,清理所有内容并重建无济于事)。

4

1 回答 1

0

我曾经通过以下方式将数据加载到DomainContext

public void GetPersonObjectDataFromService(Action<LoadOperation<TempPersonDTO>>    loadData)
    {                                           
          var query1 = this.tpDataProviderContext1.GetPersonObjectDataFromServiceQuery();
          tpDataProviderContext1.Load(query1, LoadBehavior.RefreshCurrent, loadData, null);
    }

TempPersonDTO 是具有数据的类。谢谢你。

于 2015-01-28T06:37:20.587 回答