This repository contains the following
- A .NET 3.5 library for consuming SData.
- A set of unit tests
- A WinForms application, which demonstrates various features of the API
For information about the client library and examples on how to use it, check out "Intro to SData CSharp Client Lib.doc" in the docs subfolder.
Also, keep an eye on the Wiki for up-to-date information.
Single Resources are returned to the SData Client Libraries as an AtomEntry. Simply specify the ResourceKind and Resource Selector and call the Read method of the SDataSingleResourceRequest.
var service = new SDataService("http://localhost/sdata/slx/dynamic/-/", "admin", "");�
var request = new SDataSingleResourceRequest(service)�
{�
ResourceKind = "contacts",
ResourceSelector = "'CGHEA0000001'"�
};�
var entry = request.Read();�
var payload = entry.GetSDataPayload();
Resource collections are returned to the SData Client Libraries as an AtomFeed. Simply specify the desired ResourceKind and call the Read method on the SDataResourceCollectionRequest object.
var service = new SDataService("http://localhost/sdata/slx/dynamic/-/", "admin", "");
var request = new SDataResourceCollectionRequest(service)�
{�
ResourceKind = "contacts"�
};�
var feed = request.Read();�
foreach (var entry in feed.Entries)�
{�
var payload = entry.GetSDataPayload();�
}
var contactIds = new[] {"CGHEA0002670", "CDEMOA00003A", "CDEMOA000037"};�
var service = new SDataService("http://localhost/sdata/slx/dynamic/-/", "admin", "");�
using (var batch = new SDataBatchRequest(service) {ResourceKind = "contacts"})�
{�
var request = new SDataSingleResourceRequest(service) {ResourceKind = "contacts"};�
foreach (var id in contactIds)�
{�
request.ResourceSelector = string.Format("'{0}'", id);�
request.Read();�
}�
var feed = batch.Commit();�
foreach (var entry in feed.Entries)�
{�
var values = entry.GetSDataPayload().Values;�
values.Clear(); //no need to send back unchanged values�
values["Type"] = "Decision Maker";�
request.Entry = entry;�
request.Update();�
}� feed = batch.Commit();�
foreach (var entry in feed.Entries)�
{�
Debug.Assert(entry.GetSDataHttpStatus() == HttpStatusCode.OK);�
}�
}