我真的无法弄清楚为什么在WPF客户端下RIA服务我看不到更新,插入和删除的方法。但我只能看到所有“GET”方法。
RiaService.DomainServicesoapClient proxy = new RiaService.DomainServicesoapClient( EndPointConfigurationNameData, EndpointAddress);
proxy.GetClients(); // That's OK
// But where is ????
proxy.UpdateClient(...
以下代码由Visual Studio 2010生成。
[RequiresAuthentication]
[EnableClientAccess()]
public class RiaDomainService : LinqToEntitiesDomainService<MyEntities>
{
.....
// TODO:
// Consider constraining the results of your query method. If you need additional input you can
// add parameters to this method or create additional query methods with different names.
// To support paging you will need to add ordering to the 'Clients' query.
[Query(IsDefault = true)]
public IQueryable<Client> GetClients()
{
return this.ObjectContext.Clients;
}
public void InsertClient(Client client)
{
if ((client.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(client, EntityState.Added);
}
else
{
this.ObjectContext.Clients.AddObject(client);
}
}
public void UpdateClient(Client currentClient)
{
this.ObjectContext.Clients.AttachAsModified(currentClient, this.ChangeSet.GetOriginal(currentClient));
}
public void DeleteClient(Client client)
{
if ((client.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(client, EntityState.Deleted);
}
else
{
this.ObjectContext.Clients.Attach(client);
this.ObjectContext.Clients.DeleteObject(client);
}
}
所以CRUD方法无法被RIA上下文识别出来...... 任何线索如何在客户端获得它
更新
我发现此代码的工作方式类似于CRUD
RiaService.ChangeSetEntry changeSetEntry = new RiaService.ChangeSetEntry();
changeSetEntry.Entity = {entity itslef};
changeSetEntry.Operation = RiaService.DomainOperation.Insert;
changeSetEntries.Add(changeSetEntry);
proxy.SubmitChanges(changeSetEntries.ToArray());
我的问题是:还有其他方法可以在WPF客户端下实现CRIA操作到RIA服务吗?
答案 0 :(得分:2)
根据您的更新,您似乎已经找到了以下文章,但我发帖以防其他人可能会发现它有趣,因为我认为它包含您正在寻找的信息:
答案 1 :(得分:0)
代码没有带有该签名的方法“void UpdateClient()”
你确实有......public void UpdateClient(Client currentClient)
您确定要查找的代码是否适用于正确的类(RiaService.DomainServicesoapClient)?
我无法分辨,因为您没有提供类初始化代码。