https://github.com/sage/sdatacsharpclientlib
SData .NET Client Library, written in C#, based on Microsoft Argotic
https://github.com/sage/sdatacsharpclientlib
Last synced: 7 months ago
JSON representation
SData .NET Client Library, written in C#, based on Microsoft Argotic
- Host: GitHub
- URL: https://github.com/sage/sdatacsharpclientlib
- Owner: Sage
- License: other
- Archived: true
- Created: 2010-04-22T22:35:35.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2012-12-05T20:18:52.000Z (over 13 years ago)
- Last Synced: 2025-03-24T01:37:02.376Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 3.29 MB
- Stars: 33
- Watchers: 16
- Forks: 23
- Open Issues: 6
-
Metadata Files:
- Readme: README.mdown
- License: LICENSE
Awesome Lists containing this project
README
Sage SData Client Libraries for .NET
====================================
This repository contains the following
* A .NET 3.5 library for consuming [SData](http://sdata.sage.com).
* 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](https://github.com/SageScottsdalePlatform/SDataCSharpClientLib/tree/master/docs/) subfolder.
Also, keep an eye on the [Wiki](https://github.com/SageScottsdalePlatform/SDataCSharpClientLib/wikis) for up-to-date information.
## Examples
#### Single Resources (Entry)
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 (Feed)
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();
}
#### Batch Operations
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);
}
}