Search code examples
.netwpfwcfwcf-ria-services

Insert, Update and Delete methods of RIA Services are invisible under WPF Client to RIA Services


I really cannot figured out why under the WPF client to RIA Services I cannot see methods to Update, Insert and Delete. But I can see all "GET" methods only.

RiaService.DomainServicesoapClient proxy = new RiaService.DomainServicesoapClient( EndPointConfigurationNameData, EndpointAddress);

proxy.GetClients(); // That's OK

// But where is  ????
proxy.UpdateClient(...

The code below has been generated by 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);
            }
        }

So CRUD methods not getting recognized by the RIA context... Any clue how to get it under the client side

UPDATES:

I found that this code works like a CRUD

RiaService.ChangeSetEntry changeSetEntry = new RiaService.ChangeSetEntry();
changeSetEntry.Entity = {entity itslef};
changeSetEntry.Operation = RiaService.DomainOperation.Insert;
changeSetEntries.Add(changeSetEntry);

proxy.SubmitChanges(changeSetEntries.ToArray());

My question then: Are there any other methods to realize CRUD operations under WPF client to RIA Services?


Solution

  • Based on your updates it looks like you've already found the following article, but I'm posting in case someone else might find it interesting as I believe it contains the information you're looking for:

    http://blogs.msdn.com/b/davrous/archive/2010/12/03/how-to-open-a-wcf-ria-services-application-to-other-type-of-clients-the-soap-endpoint-3-5.aspx