Blogs

The One With

OData Provider for XPO – Binding to Scheduler

     

Scheduler <-> OData <-> XPO

So far we have been focusing on creating and consuming one-way OData feeds (read-only feeds). This time, let us look at how to CREATE, UPDATE and DELETE items. CUD operations are handled by the IDataServiceUpdateProvider and this interface is fully supported by the eXpress Persistent Objects (XPO) Toolkit.

Server Side

Apart from setting the entity access rule to EntitySetRights.All, there is nothing we really need to do on the server side.

Client Side

CREATE

void CreateObject(object entity) {
    DataServiceContext service 
        = new DataServiceContext(new Uri("http://localhost:7676/Service.svc"));

    service.AddObject("<EntitySetName>", entity);

    service.SaveChanges();
}

UPDATE

void UpdateObject(object entity) {
    DataServiceContext service 
        = new DataServiceContext(new Uri("http://localhost:7676/Service.svc"));

    service.AttachTo("<EntitySetName>", entity);
    service.UpdateObject(entity);

    service.SaveChanges();
}

DELETE

void DeleteObject(object entity) {
    DataServiceContext service 
        = new DataServiceContext(new Uri("http://localhost:7676/Service.svc"));

    service.AttachTo("<EntitySetName>", entity);
    service.DeleteObject(entity);

    service.SaveChanges();
}

Sample Application

To see all CRUD operations in action download the source code for the WinForms Calendar Sample

Resources


Cheers

Azret

Published Aug 02 2010, 04:04 PM by Azret Botash (DevExpress)
Filed under: , ,
Technorati tags: XtraScheduler, XPO, OData
Bookmark and Share

Comments

No Comments
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.