Skip to content

notagan/SDataCSharpClientLib

 
 

Sage SData Client Libraries for .NET

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.

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);�    
	}� 
}

About

SData .NET Client Library, written in C#, based on Microsoft Argotic

Resources

License

Unknown and 4 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE.Argotic
Unknown
LICENSE.LINQBridge
Unknown
LICENSE.Moq
Unknown
LICENSE.NUnit

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%