我已将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服务1.0 SP2,清理一切并重建没有帮助)。
答案 0 :(得分:0)
我曾经通过以下方式将数据加载到 DomainContext 。
public void GetPersonObjectDataFromService(Action<LoadOperation<TempPersonDTO>> loadData)
{
var query1 = this.tpDataProviderContext1.GetPersonObjectDataFromServiceQuery();
tpDataProviderContext1.Load(query1, LoadBehavior.RefreshCurrent, loadData, null);
}
TempPersonDTO是具有数据的类。 谢谢。